Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
5f834ab1
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
9 个月 前同步成功
通知
8
Star
18
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5f834ab1
编写于
7月 03, 2008
作者:
G
Geoff Thorpe
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert my earlier CRYPTO_THREADID commit, I will commit a reworked
version some time soon.
上级
8528128b
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
161 addition
and
290 deletion
+161
-290
CHANGES
CHANGES
+0
-65
apps/apps.h
apps/apps.h
+2
-2
crypto/bn/bn.h
crypto/bn/bn.h
+2
-5
crypto/bn/bn_blind.c
crypto/bn/bn_blind.c
+6
-11
crypto/bn/exptest.c
crypto/bn/exptest.c
+1
-1
crypto/cryptlib.c
crypto/cryptlib.c
+34
-63
crypto/crypto.h
crypto/crypto.h
+3
-28
crypto/dsa/dsatest.c
crypto/dsa/dsatest.c
+1
-1
crypto/ec/ectest.c
crypto/ec/ectest.c
+1
-1
crypto/ecdh/ecdhtest.c
crypto/ecdh/ecdhtest.c
+1
-1
crypto/ecdsa/ecdsatest.c
crypto/ecdsa/ecdsatest.c
+1
-1
crypto/engine/enginetest.c
crypto/engine/enginetest.c
+1
-1
crypto/err/err.c
crypto/err/err.c
+22
-18
crypto/err/err.h
crypto/err/err.h
+1
-6
crypto/err/err_prn.c
crypto/err/err_prn.c
+1
-3
crypto/evp/evp_test.c
crypto/evp/evp_test.c
+1
-1
crypto/mem_dbg.c
crypto/mem_dbg.c
+56
-36
crypto/rand/md_rand.c
crypto/rand/md_rand.c
+8
-9
crypto/rsa/rsa_eay.c
crypto/rsa/rsa_eay.c
+1
-3
crypto/rsa/rsa_lib.c
crypto/rsa/rsa_lib.c
+2
-1
crypto/rsa/rsa_test.c
crypto/rsa/rsa_test.c
+1
-1
doc/crypto/BN_BLINDING_new.pod
doc/crypto/BN_BLINDING_new.pod
+8
-23
doc/crypto/bn.pod
doc/crypto/bn.pod
+2
-4
doc/crypto/threads.pod
doc/crypto/threads.pod
+4
-4
ssl/ssltest.c
ssl/ssltest.c
+1
-1
未找到文件。
CHANGES
浏览文件 @
5f834ab1
...
...
@@ -20,63 +20,6 @@
STACK, TXT_DB, bsearch, qsort.
[Ben Laurie]
*) Not all of this is true any longer.
Will have to be updated to reflect all subsequent changes to cryptlib.c.
--bodo
To support arbitrarily-typed thread IDs, deprecate the existing
type-specific APIs for a general purpose CRYPTO_THREADID
interface. Applications can choose the thread ID
callback type it wishes to register, as before;
void CRYPTO_set_id_callback(unsigned long (*func)(void));
void CRYPTO_set_idptr_callback(void *(*func)(void));
but retrieval, copies, and comparisons of thread IDs are via
type-independent interfaces;
void CRYPTO_THREADID_set(CRYPTO_THREADID *id);
void CRYPTO_THREADID_cmp(const CRYPTO_THREADID *id1,
const CRYPTO_THREADID *id2);
void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dst,
const CRYPTO_THREADID *src);
Also, for code that needs a thread ID "value" for use in
hash-tables or logging, a "hash" is available by;
unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id);
This hash value is likely to be the thread ID anyway, but
otherwise it will be unique if possible or as collision-free as
possible if uniqueness can't be guaranteed on the target
architecture.
The following functions are deprecated;
unsigned long (*CRYPTO_get_id_callback(void))(void);
unsigned long CRYPTO_thread_id(void);
As a consequence of the above, there are similar deprecations of
BN_BLINDING functions in favour of CRYPTO_THREADID-based
alternatives;
#ifndef OPENSSL_NO_DEPRECATED
unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);
void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);
#endif
void BN_BLINDING_set_thread(BN_BLINDING *);
int BN_BLINDING_cmp_thread(const BN_BLINDING *, const
CRYPTO_THREADID *);
Also, the ERR_remove_state(int pid) API has been deprecated;
#ifndef OPENSSL_NO_DEPRECATED
void ERR_remove_state(unsigned long pid)
#endif
void ERR_remove_thread_state(CRYPTO_THREADID *tid);
[Geoff Thorpe]
*) Initial support for Cryptographic Message Syntax (aka CMS) based
on RFC3850, RFC3851 and RFC3852. New cms directory and cms utility,
support for data, signedData, compressedData, digestedData and
...
...
@@ -383,14 +326,6 @@
callback is &errno.
[Bodo Moeller]
-- NOTE -- this change has been reverted and replaced with a
type-independent wrapper (ie. applications do not have to check
two type-specific thread ID representations as implied in this
change note). However, the "idptr" callback form described here
can still be registered. Please see the more recent CHANGES note
regarding CRYPTO_THREADID. [Geoff Thorpe]
-- NOTE --
*) Change the array representation of binary polynomials: the list
of degrees of non-zero coefficients is now terminated with -1.
Previously it was terminated with 0, which was also part of the
...
...
apps/apps.h
浏览文件 @
5f834ab1
...
...
@@ -181,7 +181,7 @@ extern BIO *bio_err;
# define apps_shutdown() \
do { CONF_modules_unload(1); destroy_ui_method(); \
OBJ_cleanup(); EVP_cleanup(); ENGINE_cleanup(); \
CRYPTO_cleanup_all_ex_data(); ERR_remove_
thread_state(NULL
); \
CRYPTO_cleanup_all_ex_data(); ERR_remove_
state(0
); \
ERR_free_strings(); COMP_zlib_cleanup();} while(0)
# else
# define apps_startup() \
...
...
@@ -191,7 +191,7 @@ extern BIO *bio_err;
# define apps_shutdown() \
do { CONF_modules_unload(1); destroy_ui_method(); \
OBJ_cleanup(); EVP_cleanup(); \
CRYPTO_cleanup_all_ex_data(); ERR_remove_
thread_state(NULL
); \
CRYPTO_cleanup_all_ex_data(); ERR_remove_
state(0
); \
ERR_free_strings(); } while(0)
# endif
#endif
...
...
crypto/bn/bn.h
浏览文件 @
5f834ab1
...
...
@@ -129,7 +129,6 @@
#ifndef OPENSSL_NO_FP_API
#include <stdio.h>
/* FILE */
#endif
#include <openssl/crypto.h>
#include <openssl/ossl_typ.h>
#ifdef __cplusplus
...
...
@@ -565,12 +564,10 @@ int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
int
BN_BLINDING_invert
(
BIGNUM
*
n
,
BN_BLINDING
*
b
,
BN_CTX
*
ctx
);
int
BN_BLINDING_convert_ex
(
BIGNUM
*
n
,
BIGNUM
*
r
,
BN_BLINDING
*
b
,
BN_CTX
*
);
int
BN_BLINDING_invert_ex
(
BIGNUM
*
n
,
const
BIGNUM
*
r
,
BN_BLINDING
*
b
,
BN_CTX
*
);
#ifndef OPENSSL_NO_DEPRECATED
unsigned
long
BN_BLINDING_get_thread_id
(
const
BN_BLINDING
*
);
void
BN_BLINDING_set_thread_id
(
BN_BLINDING
*
,
unsigned
long
);
#endif
void
BN_BLINDING_set_thread
(
BN_BLINDING
*
);
int
BN_BLINDING_cmp_thread
(
const
BN_BLINDING
*
,
const
CRYPTO_THREADID
*
);
void
*
BN_BLINDING_get_thread_idptr
(
const
BN_BLINDING
*
);
void
BN_BLINDING_set_thread_idptr
(
BN_BLINDING
*
,
void
*
);
unsigned
long
BN_BLINDING_get_flags
(
const
BN_BLINDING
*
);
void
BN_BLINDING_set_flags
(
BN_BLINDING
*
,
unsigned
long
);
BN_BLINDING
*
BN_BLINDING_create_param
(
BN_BLINDING
*
b
,
...
...
crypto/bn/bn_blind.c
浏览文件 @
5f834ab1
...
...
@@ -121,13 +121,10 @@ struct bn_blinding_st
BIGNUM
*
Ai
;
BIGNUM
*
e
;
BIGNUM
*
mod
;
/* just a reference */
/* FIXME: should really try to remove these, but the deprecated APIs that are
* using them would need to be fudged somehow. */
#ifndef OPENSSL_NO_DEPRECATED
unsigned
long
thread_id
;
/* added in OpenSSL 0.9.6j and 0.9.7b;
* used only by crypto/rsa/rsa_eay.c, rsa_lib.c */
#endif
CRYPTO_THREADID
tid
;
void
*
thread_idptr
;
/* added in OpenSSL 0.9.9;
* used only by crypto/rsa/rsa_eay.c, rsa_lib.c */
unsigned
int
counter
;
unsigned
long
flags
;
BN_MONT_CTX
*
m_ctx
;
...
...
@@ -268,7 +265,6 @@ int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *ct
return
(
ret
);
}
#ifndef OPENSSL_NO_DEPRECATED
unsigned
long
BN_BLINDING_get_thread_id
(
const
BN_BLINDING
*
b
)
{
return
b
->
thread_id
;
...
...
@@ -278,16 +274,15 @@ void BN_BLINDING_set_thread_id(BN_BLINDING *b, unsigned long n)
{
b
->
thread_id
=
n
;
}
#endif
void
BN_BLINDING_set_thread
(
BN_BLINDING
*
b
)
void
*
BN_BLINDING_get_thread_idptr
(
const
BN_BLINDING
*
b
)
{
CRYPTO_THREADID_set
(
&
b
->
tid
)
;
return
b
->
thread_idptr
;
}
int
BN_BLINDING_cmp_thread
(
const
BN_BLINDING
*
b
,
const
CRYPTO_THREADID
*
tid
)
void
BN_BLINDING_set_thread_idptr
(
BN_BLINDING
*
b
,
void
*
p
)
{
return
CRYPTO_THREADID_cmp
(
&
b
->
tid
,
tid
)
;
b
->
thread_idptr
=
p
;
}
unsigned
long
BN_BLINDING_get_flags
(
const
BN_BLINDING
*
b
)
...
...
crypto/bn/exptest.c
浏览文件 @
5f834ab1
...
...
@@ -187,7 +187,7 @@ int main(int argc, char *argv[])
BN_free
(
b
);
BN_free
(
m
);
BN_CTX_free
(
ctx
);
ERR_remove_
thread_state
(
NULL
);
ERR_remove_
state
(
0
);
CRYPTO_mem_leaks
(
out
);
BIO_free
(
out
);
printf
(
" done
\n
"
);
...
...
crypto/cryptlib.c
浏览文件 @
5f834ab1
...
...
@@ -414,60 +414,14 @@ void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
add_lock_callback
=
func
;
}
/* Thread IDs. So ... if we build without OPENSSL_NO_DEPRECATED, then we leave
* the existing implementations and just layer CRYPTO_THREADID_[get|cmp]
* harmlessly on top. Otherwise, we only use 'id_callback' or 'idptr_callback'
* if they're non-NULL, ie. we ignore CRYPTO_thread_id()'s fallbacks and we
* move CRYPTO_thread_idptr()'s "&errno" fallback trick into
* CRYPTO_THREADID_set(). */
void
CRYPTO_set_id_callback
(
unsigned
long
(
*
func
)(
void
))
{
id_callback
=
func
;
}
void
CRYPTO_set_idptr_callback
(
void
*
(
*
func
)(
void
))
{
idptr_callback
=
func
;
}
void
CRYPTO_THREADID_set
(
CRYPTO_THREADID
*
id
)
{
if
(
id_callback
)
id
->
ulong
=
id_callback
();
else
id
->
ulong
=
0
;
if
(
idptr_callback
)
id
->
ptr
=
idptr_callback
();
else
id
->
ptr
=
&
errno
;
}
int
CRYPTO_THREADID_cmp
(
const
CRYPTO_THREADID
*
id1
,
const
CRYPTO_THREADID
*
id2
)
{
if
(
id1
->
ulong
!=
id2
->
ulong
)
return
((
id1
->
ulong
<
id2
->
ulong
)
?
-
1
:
1
);
if
(
id1
->
ptr
!=
id2
->
ptr
)
return
((
id1
->
ptr
<
id2
->
ptr
)
?
-
1
:
1
);
return
0
;
}
unsigned
long
CRYPTO_THREADID_hash
(
const
CRYPTO_THREADID
*
id
)
{
/* will need further processing to arrive at a good hash (mem_dbg.c uses this) */
return
id
->
ulong
+
(
unsigned
long
)
id
->
ptr
;
}
void
CRYPTO_THREADID_cpy
(
CRYPTO_THREADID
*
dst
,
const
CRYPTO_THREADID
*
src
)
unsigned
long
(
*
CRYPTO_get_id_callback
(
void
))(
void
)
{
memcpy
(
dst
,
src
,
sizeof
(
*
src
)
);
return
(
id_callback
);
}
#ifndef OPENSSL_NO_DEPRECATED
unsigned
long
(
*
CRYPTO_get_id_callback
(
void
))(
void
)
void
CRYPTO_set_id_callback
(
unsigned
long
(
*
func
)(
void
))
{
return
(
id_callback
)
;
id_callback
=
func
;
}
unsigned
long
CRYPTO_thread_id
(
void
)
...
...
@@ -492,14 +446,34 @@ unsigned long CRYPTO_thread_id(void)
ret
=
id_callback
();
return
(
ret
);
}
#endif
void
*
(
*
CRYPTO_get_idptr_callback
(
void
))(
void
)
{
return
(
idptr_callback
);
}
void
CRYPTO_set_idptr_callback
(
void
*
(
*
func
)(
void
))
{
idptr_callback
=
func
;
}
void
*
CRYPTO_thread_idptr
(
void
)
{
void
*
ret
=
NULL
;
if
(
idptr_callback
==
NULL
)
ret
=
&
errno
;
else
ret
=
idptr_callback
();
return
ret
;
}
void
CRYPTO_lock
(
int
mode
,
int
type
,
const
char
*
file
,
int
line
)
{
#ifdef LOCK_DEBUG
{
char
*
rw_text
,
*
operation_text
;
CRYPTO_THREADID
tid
;
if
(
mode
&
CRYPTO_LOCK
)
operation_text
=
"lock "
;
...
...
@@ -515,9 +489,8 @@ void CRYPTO_lock(int mode, int type, const char *file, int line)
else
rw_text
=
"ERROR"
;
CRYPTO_THREADID_set
(
&
tid
);
fprintf
(
stderr
,
"lock:%08lx:(%s)%s %-18s %s:%d
\n
"
,
CRYPTO_THREADID_hash
(
&
tid
),
rw_text
,
operation_text
,
fprintf
(
stderr
,
"lock:%08lx/%08p:(%s)%s %-18s %s:%d
\n
"
,
CRYPTO_thread_id
(),
CRYPTO_thread_idptr
(),
rw_text
,
operation_text
,
CRYPTO_get_lock_name
(
type
),
file
,
line
);
}
#endif
...
...
@@ -544,10 +517,6 @@ int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
int
line
)
{
int
ret
=
0
;
#ifdef LOCK_DEBUG
CRYPTO_THREADID
tid
;
CRYPTO_THREADID_set
(
&
tid
);
#endif
if
(
add_lock_callback
!=
NULL
)
{
...
...
@@ -557,8 +526,9 @@ int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
ret
=
add_lock_callback
(
pointer
,
amount
,
type
,
file
,
line
);
#ifdef LOCK_DEBUG
fprintf
(
stderr
,
"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d
\n
"
,
CRYPTO_THREADID_hash
(
&
tid
),
before
,
amount
,
ret
,
fprintf
(
stderr
,
"ladd:%08lx/%0xp:%2d+%2d->%2d %-18s %s:%d
\n
"
,
CRYPTO_thread_id
(),
CRYPTO_thread_idptr
(),
before
,
amount
,
ret
,
CRYPTO_get_lock_name
(
type
),
file
,
line
);
#endif
...
...
@@ -569,8 +539,9 @@ int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
ret
=
*
pointer
+
amount
;
#ifdef LOCK_DEBUG
fprintf
(
stderr
,
"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d
\n
"
,
CRYPTO_THREADID_hash
(
&
tid
),
*
pointer
,
amount
,
ret
,
fprintf
(
stderr
,
"ladd:%08lx/%0xp:%2d+%2d->%2d %-18s %s:%d
\n
"
,
CRYPTO_thread_id
(),
CRYPTO_thread_idptr
(),
*
pointer
,
amount
,
ret
,
CRYPTO_get_lock_name
(
type
),
file
,
line
);
#endif
...
...
crypto/crypto.h
浏览文件 @
5f834ab1
...
...
@@ -301,17 +301,6 @@ typedef struct crypto_ex_data_func_st
DECLARE_STACK_OF
(
CRYPTO_EX_DATA_FUNCS
)
/* This structure is exposed to allow it to be used without dynamic allocation,
* however it exists to encapsulate the different ways of representing "thread
* ID"s (given that applications provide the thread implementation via
* callbacks). So treat this type as opaque if you don't want your code to fall
* apart when someone decides to extend this in some way. */
typedef
struct
crypto_threadid
{
unsigned
long
ulong
;
void
*
ptr
;
}
CRYPTO_THREADID
;
/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA
* entry.
*/
...
...
@@ -432,26 +421,12 @@ void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
const
char
*
file
,
int
line
));
int
(
*
CRYPTO_get_add_lock_callback
(
void
))(
int
*
num
,
int
mount
,
int
type
,
const
char
*
file
,
int
line
);
/* Implement "thread ID" via callback, choose the prototype that matches your
* thread implementation. */
void
CRYPTO_set_id_callback
(
unsigned
long
(
*
func
)(
void
));
void
CRYPTO_set_idptr_callback
(
void
*
(
*
func
)(
void
));
/* Records the thread ID of the currently executing thread */
void
CRYPTO_THREADID_set
(
CRYPTO_THREADID
*
id
);
/* Compares two thread IDs. If the underlying notion of thread ID is linear,
* this returns -1, 0, or +1 to imply strict-ordering (as other ***_cmp()
* functions do). Otherwise, zero means equal, non-zero means not equal. */
int
CRYPTO_THREADID_cmp
(
const
CRYPTO_THREADID
*
id1
,
const
CRYPTO_THREADID
*
id2
);
/* When you need "a number", eg. for hashing, use this. */
unsigned
long
CRYPTO_THREADID_hash
(
const
CRYPTO_THREADID
*
id
);
/* Copy a threadid */
void
CRYPTO_THREADID_cpy
(
CRYPTO_THREADID
*
dst
,
const
CRYPTO_THREADID
*
src
);
#ifndef OPENSSL_NO_DEPRECATED
/* Deprecated interfaces - these presume you know exactly what's going on under
* the covers. Better to migrate to the CRYPTO_THREADID_***() form. */
unsigned
long
(
*
CRYPTO_get_id_callback
(
void
))(
void
);
unsigned
long
CRYPTO_thread_id
(
void
);
#endif
void
CRYPTO_set_idptr_callback
(
void
*
(
*
func
)(
void
));
void
*
(
*
CRYPTO_get_idptr_callback
(
void
))(
void
);
void
*
CRYPTO_thread_idptr
(
void
);
const
char
*
CRYPTO_get_lock_name
(
int
type
);
int
CRYPTO_add_lock
(
int
*
pointer
,
int
amount
,
int
type
,
const
char
*
file
,
...
...
crypto/dsa/dsatest.c
浏览文件 @
5f834ab1
...
...
@@ -222,7 +222,7 @@ end:
ERR_print_errors
(
bio_err
);
if
(
dsa
!=
NULL
)
DSA_free
(
dsa
);
CRYPTO_cleanup_all_ex_data
();
ERR_remove_
thread_state
(
NULL
);
ERR_remove_
state
(
0
);
ERR_free_strings
();
CRYPTO_mem_leaks
(
bio_err
);
if
(
bio_err
!=
NULL
)
...
...
crypto/ec/ectest.c
浏览文件 @
5f834ab1
...
...
@@ -1326,7 +1326,7 @@ int main(int argc, char *argv[])
#endif
CRYPTO_cleanup_all_ex_data
();
ERR_free_strings
();
ERR_remove_
thread_state
(
NULL
);
ERR_remove_
state
(
0
);
CRYPTO_mem_leaks_fp
(
stderr
);
return
0
;
...
...
crypto/ecdh/ecdhtest.c
浏览文件 @
5f834ab1
...
...
@@ -343,7 +343,7 @@ err:
if
(
ctx
)
BN_CTX_free
(
ctx
);
BIO_free
(
out
);
CRYPTO_cleanup_all_ex_data
();
ERR_remove_
thread_state
(
NULL
);
ERR_remove_
state
(
0
);
CRYPTO_mem_leaks_fp
(
stderr
);
EXIT
(
ret
);
return
(
ret
);
...
...
crypto/ecdsa/ecdsatest.c
浏览文件 @
5f834ab1
...
...
@@ -490,7 +490,7 @@ err:
if
(
ret
)
ERR_print_errors
(
out
);
CRYPTO_cleanup_all_ex_data
();
ERR_remove_
thread_state
(
NULL
);
ERR_remove_
state
(
0
);
ERR_free_strings
();
CRYPTO_mem_leaks
(
out
);
if
(
out
!=
NULL
)
...
...
crypto/engine/enginetest.c
浏览文件 @
5f834ab1
...
...
@@ -276,7 +276,7 @@ end:
ENGINE_cleanup
();
CRYPTO_cleanup_all_ex_data
();
ERR_free_strings
();
ERR_remove_
thread_state
(
NULL
);
ERR_remove_
state
(
0
);
CRYPTO_mem_leaks_fp
(
stderr
);
return
to_return
;
}
...
...
crypto/err/err.c
浏览文件 @
5f834ab1
...
...
@@ -429,13 +429,13 @@ static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d)
static
unsigned
long
err_state_hash
(
const
ERR_STATE
*
a
)
{
return
CRYPTO_THREADID_hash
(
&
a
->
tid
)
;
return
(
a
->
pid
+
(
unsigned
long
)
a
->
pidptr
)
*
13
;
}
static
IMPLEMENT_LHASH_HASH_FN
(
err_state
,
ERR_STATE
)
static
int
err_state_cmp
(
const
ERR_STATE
*
a
,
const
ERR_STATE
*
b
)
{
return
CRYPTO_THREADID_cmp
(
&
a
->
tid
,
&
b
->
tid
);
return
(
a
->
pid
!=
b
->
pid
)
||
(
a
->
pidptr
!=
b
->
pidptr
);
}
static
IMPLEMENT_LHASH_COMP_FN
(
err_state
,
ERR_STATE
)
...
...
@@ -980,37 +980,40 @@ const char *ERR_reason_error_string(unsigned long e)
return
((
p
==
NULL
)
?
NULL
:
p
->
string
);
}
void
ERR_remove_
thread_state
(
CRYPTO_THREADID
*
t
id
)
void
ERR_remove_
state
(
unsigned
long
p
id
)
{
ERR_STATE
tmp
;
void
*
pidptr
;
if
(
tid
)
CRYPTO_THREADID_cpy
(
&
tmp
.
tid
,
tid
);
else
CRYPTO_THREADID_set
(
&
tmp
.
tid
);
err_fns_check
();
if
(
pid
!=
0
)
pidptr
=
&
errno
;
else
{
pid
=
CRYPTO_thread_id
();
pidptr
=
CRYPTO_thread_idptr
();
}
tmp
.
pid
=
pid
;
tmp
.
pidptr
=
pidptr
;
/* thread_del_item automatically destroys the LHASH if the number of
* items reaches zero. */
ERRFN
(
thread_del_item
)(
&
tmp
);
}
#ifndef OPENSSL_NO_DEPRECATED
void
ERR_remove_state
(
unsigned
long
pid
)
{
ERR_remove_thread_state
(
NULL
);
}
#endif
ERR_STATE
*
ERR_get_state
(
void
)
{
static
ERR_STATE
fallback
;
CRYPTO_THREADID
tid
;
ERR_STATE
*
ret
,
tmp
,
*
tmpp
=
NULL
;
int
i
;
unsigned
long
pid
;
void
*
pidptr
;
err_fns_check
();
CRYPTO_THREADID_set
(
&
tid
);
CRYPTO_THREADID_cpy
(
&
tmp
.
tid
,
&
tid
);
pid
=
CRYPTO_thread_id
();
pidptr
=
CRYPTO_thread_idptr
();
tmp
.
pid
=
pid
;
tmp
.
pidptr
=
pidptr
;
ret
=
ERRFN
(
thread_get_item
)(
&
tmp
);
/* ret == the error state, if NULL, make a new one */
...
...
@@ -1018,7 +1021,8 @@ ERR_STATE *ERR_get_state(void)
{
ret
=
(
ERR_STATE
*
)
OPENSSL_malloc
(
sizeof
(
ERR_STATE
));
if
(
ret
==
NULL
)
return
(
&
fallback
);
CRYPTO_THREADID_cpy
(
&
ret
->
tid
,
&
tid
);
ret
->
pid
=
pid
;
ret
->
pidptr
=
pidptr
;
ret
->
top
=
0
;
ret
->
bottom
=
0
;
for
(
i
=
0
;
i
<
ERR_NUM_ERRORS
;
i
++
)
...
...
crypto/err/err.h
浏览文件 @
5f834ab1
...
...
@@ -147,10 +147,8 @@ extern "C" {
#define ERR_NUM_ERRORS 16
typedef
struct
err_state_st
{
#ifndef OPENSSL_NO_DEPRECATED
unsigned
long
pid
;
#endif
CRYPTO_THREADID
tid
;
void
*
pidptr
;
/* new in OpenSSL 0.9.9 */
int
err_flags
[
ERR_NUM_ERRORS
];
unsigned
long
err_buffer
[
ERR_NUM_ERRORS
];
char
*
err_data
[
ERR_NUM_ERRORS
];
...
...
@@ -353,10 +351,7 @@ void ERR_load_ERR_strings(void);
void
ERR_load_crypto_strings
(
void
);
void
ERR_free_strings
(
void
);
void
ERR_remove_thread_state
(
CRYPTO_THREADID
*
tid
);
#ifndef OPENSSL_NO_DEPRECATED
void
ERR_remove_state
(
unsigned
long
pid
);
/* if zero we look it up */
#endif
ERR_STATE
*
ERR_get_state
(
void
);
#ifndef OPENSSL_NO_LHASH
...
...
crypto/err/err_prn.c
浏览文件 @
5f834ab1
...
...
@@ -72,10 +72,8 @@ void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
const
char
*
file
,
*
data
;
int
line
,
flags
;
unsigned
long
es
;
CRYPTO_THREADID
tid
;
CRYPTO_THREADID_set
(
&
tid
);
es
=
CRYPTO_THREADID_hash
(
&
tid
);
es
=
CRYPTO_thread_id
();
while
((
l
=
ERR_get_error_line_data
(
&
file
,
&
line
,
&
data
,
&
flags
))
!=
0
)
{
ERR_error_string_n
(
l
,
buf
,
sizeof
buf
);
...
...
crypto/evp/evp_test.c
浏览文件 @
5f834ab1
...
...
@@ -441,7 +441,7 @@ int main(int argc,char **argv)
#endif
EVP_cleanup
();
CRYPTO_cleanup_all_ex_data
();
ERR_remove_
thread_state
(
NULL
);
ERR_remove_
state
(
0
);
ERR_free_strings
();
CRYPTO_mem_leaks_fp
(
stderr
);
...
...
crypto/mem_dbg.c
浏览文件 @
5f834ab1
...
...
@@ -150,7 +150,8 @@ typedef struct app_mem_info_st
* CRYPTO_remove_all_info() to pop all entries.
*/
{
CRYPTO_THREADID
threadid
;
unsigned
long
thread_id
;
void
*
thread_idptr
;
const
char
*
file
;
int
line
;
const
char
*
info
;
...
...
@@ -175,7 +176,8 @@ typedef struct mem_st
int
num
;
const
char
*
file
;
int
line
;
CRYPTO_THREADID
threadid
;
unsigned
long
thread_id
;
void
*
thread_idptr
;
unsigned
long
order
;
time_t
time
;
APP_INFO
*
app_info
;
...
...
@@ -196,9 +198,12 @@ static unsigned int num_disable = 0; /* num_disable > 0
* mh_mode == CRYPTO_MEM_CHECK_ON (w/o ..._ENABLE)
*/
/* Valid iff num_disable > 0. CRYPTO_LOCK_MALLOC2 is locked exactly in this
* case (by the thread named in disabling_threadid). */
static
CRYPTO_THREADID
disabling_threadid
;
/* The following two variables, disabling_thread_id and disabling_thread_idptr,
* are valid iff num_disable > 0. CRYPTO_LOCK_MALLOC2 is locked exactly in
* this case (by the thread named in disabling_thread_id / disabling_thread_idptr).
*/
static
unsigned
long
disabling_thread_id
=
0
;
static
void
*
disabling_thread_idptr
=
NULL
;
static
void
app_info_free
(
APP_INFO
*
inf
)
{
...
...
@@ -235,10 +240,9 @@ int CRYPTO_mem_ctrl(int mode)
case
CRYPTO_MEM_CHECK_DISABLE
:
/* aka MemCheck_off() */
if
(
mh_mode
&
CRYPTO_MEM_CHECK_ON
)
{
CRYPTO_THREADID
tid
;
CRYPTO_THREADID_set
(
&
tid
);
if
(
!
num_disable
||
CRYPTO_THREADID_cmp
(
&
tid
,
&
disabling_threadid
))
if
(
!
num_disable
||
(
disabling_thread_id
!=
CRYPTO_thread_id
())
||
(
disabling_thread_idptr
!=
CRYPTO_thread_idptr
()))
/* otherwise we already have the MALLOC2 lock */
{
/* Long-time lock CRYPTO_LOCK_MALLOC2 must not be claimed while
* we're holding CRYPTO_LOCK_MALLOC, or we'll deadlock if
...
...
@@ -256,7 +260,8 @@ int CRYPTO_mem_ctrl(int mode)
CRYPTO_w_lock
(
CRYPTO_LOCK_MALLOC2
);
CRYPTO_w_lock
(
CRYPTO_LOCK_MALLOC
);
mh_mode
&=
~
CRYPTO_MEM_CHECK_ENABLE
;
CRYPTO_THREADID_set
(
&
disabling_threadid
);
disabling_thread_id
=
CRYPTO_thread_id
();
disabling_thread_idptr
=
CRYPTO_thread_idptr
();
}
num_disable
++
;
}
...
...
@@ -289,12 +294,11 @@ int CRYPTO_is_mem_check_on(void)
if
(
mh_mode
&
CRYPTO_MEM_CHECK_ON
)
{
CRYPTO_THREADID
tid
;
CRYPTO_THREADID_set
(
&
tid
);
CRYPTO_r_lock
(
CRYPTO_LOCK_MALLOC
);
ret
=
(
mh_mode
&
CRYPTO_MEM_CHECK_ENABLE
)
||
CRYPTO_THREADID_cmp
(
&
tid
,
&
disabling_threadid
);
ret
=
(
mh_mode
&
CRYPTO_MEM_CHECK_ENABLE
)
||
(
disabling_thread_id
!=
CRYPTO_thread_id
())
||
(
disabling_thread_idptr
!=
CRYPTO_thread_idptr
());
CRYPTO_r_unlock
(
CRYPTO_LOCK_MALLOC
);
}
...
...
@@ -340,15 +344,20 @@ static IMPLEMENT_LHASH_HASH_FN(mem, MEM)
/* static int app_info_cmp(APP_INFO *a, APP_INFO *b) */
static
int
app_info_cmp
(
const
void
*
a_void
,
const
void
*
b_void
)
{
return
CRYPTO_THREADID_cmp
(
&
((
const
APP_INFO
*
)
a_void
)
->
threadid
,
&
((
const
APP_INFO
*
)
b_void
)
->
threadid
);
return
(((
const
APP_INFO
*
)
a_void
)
->
thread_id
!=
((
const
APP_INFO
*
)
b_void
)
->
thread_id
)
||
(((
const
APP_INFO
*
)
a_void
)
->
thread_idptr
!=
((
const
APP_INFO
*
)
b_void
)
->
thread_idptr
);
}
static
IMPLEMENT_LHASH_COMP_FN
(
app_info
,
APP_INFO
)
static
unsigned
long
app_info_hash
(
const
APP_INFO
*
a
)
{
unsigned
long
id1
,
id2
;
unsigned
long
ret
;
ret
=
CRYPTO_THREADID_hash
(
&
a
->
threadid
);
id1
=
(
unsigned
long
)
a
->
thread_id
;
id2
=
(
unsigned
long
)
a
->
thread_idptr
;
ret
=
id1
+
id2
;
ret
=
ret
*
17851
+
(
ret
>>
14
)
*
7
+
(
ret
>>
4
)
*
251
;
return
(
ret
);
}
...
...
@@ -361,7 +370,8 @@ static APP_INFO *pop_info(void)
if
(
amih
!=
NULL
)
{
CRYPTO_THREADID_set
(
&
tmp
.
threadid
);
tmp
.
thread_id
=
CRYPTO_thread_id
();
tmp
.
thread_idptr
=
CRYPTO_thread_idptr
();
if
((
ret
=
lh_APP_INFO_delete
(
amih
,
&
tmp
))
!=
NULL
)
{
APP_INFO
*
next
=
ret
->
next
;
...
...
@@ -372,11 +382,10 @@ static APP_INFO *pop_info(void)
lh_APP_INFO_insert
(
amih
,
next
);
}
#ifdef LEVITTE_DEBUG_MEM
if
(
CRYPTO_THREADID_cmp
(
&
ret
->
threadid
,
&
tmp
.
threadid
)
)
if
(
ret
->
thread_id
!=
tmp
.
thread_id
||
ret
->
thread_idptr
!=
tmp
.
thread_idptr
)
{
fprintf
(
stderr
,
"pop_info(): deleted info has other thread ID (%lu) than the current thread (%lu)!!!!
\n
"
,
CRYPTO_THREADID_hash
(
&
ret
->
threadid
),
CRYPTO_THREADID_hash
(
&
tmp
.
threadid
));
fprintf
(
stderr
,
"pop_info(): deleted info has other thread ID (%lu/%p) than the current thread (%lu/%p)!!!!
\n
"
,
ret
->
thread_id
,
ret
->
thread_idptr
,
tmp
.
thread_id
,
tmp
.
thread_idptr
);
abort
();
}
#endif
...
...
@@ -416,7 +425,8 @@ int CRYPTO_push_info_(const char *info, const char *file, int line)
}
}
CRYPTO_THREADID_set
(
&
ami
->
threadid
);
ami
->
thread_id
=
CRYPTO_thread_id
();
ami
->
thread_idptr
=
CRYPTO_thread_idptr
();
ami
->
file
=
file
;
ami
->
line
=
line
;
ami
->
info
=
info
;
...
...
@@ -426,11 +436,10 @@ int CRYPTO_push_info_(const char *info, const char *file, int line)
if
((
amim
=
lh_APP_INFO_insert
(
amih
,
ami
))
!=
NULL
)
{
#ifdef LEVITTE_DEBUG_MEM
if
(
CRYPTO_THREADID_cmp
(
&
ami
->
threadid
,
&
amim
->
threadid
)
)
if
(
ami
->
thread_id
!=
amim
->
thread_id
||
ami
->
thread_idptr
!=
amim
->
thread_idptr
)
{
fprintf
(
stderr
,
"CRYPTO_push_info(): previous info has other thread ID (%lu) than the current thread (%lu)!!!!
\n
"
,
CRYPTO_THREADID_hash
(
&
amim
->
threadid
),
CRYPTO_THREADID_hash
(
&
ami
->
threadid
));
fprintf
(
stderr
,
"CRYPTO_push_info(): previous info has other thread ID (%lu/%p) than the current thread (%lu/%p)!!!!
\n
"
,
amim
->
thread_id
,
amim
->
thread_idptr
,
ami
->
thread_id
,
ami
->
thread_idptr
);
abort
();
}
#endif
...
...
@@ -515,7 +524,16 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
m
->
file
=
file
;
m
->
line
=
line
;
m
->
num
=
num
;
CRYPTO_THREADID_set
(
&
m
->
threadid
);
if
(
options
&
V_CRYPTO_MDEBUG_THREAD
)
{
m
->
thread_id
=
CRYPTO_thread_id
();
m
->
thread_idptr
=
CRYPTO_thread_idptr
();
}
else
{
m
->
thread_id
=
0
;
m
->
thread_idptr
=
NULL
;
}
if
(
order
==
break_order_num
)
{
...
...
@@ -534,7 +552,8 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
else
m
->
time
=
0
;
CRYPTO_THREADID_set
(
&
m
->
threadid
);
tmp
.
thread_id
=
CRYPTO_thread_id
();
tmp
.
thread_idptr
=
CRYPTO_thread_idptr
();
m
->
app_info
=
NULL
;
if
(
amih
!=
NULL
&&
(
amim
=
lh_APP_INFO_retrieve
(
amih
,
&
tmp
))
!=
NULL
)
...
...
@@ -663,7 +682,8 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
APP_INFO
*
amip
;
int
ami_cnt
;
struct
tm
*
lcl
=
NULL
;
CRYPTO_THREADID
tid
;
unsigned
long
ti
;
void
*
tip
;
#define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))
...
...
@@ -685,8 +705,7 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
if
(
options
&
V_CRYPTO_MDEBUG_THREAD
)
{
BIO_snprintf
(
bufp
,
BUF_REMAIN
,
"thread=%lu, "
,
CRYPTO_THREADID_hash
(
&
m
->
threadid
));
BIO_snprintf
(
bufp
,
BUF_REMAIN
,
"thread=%lu/%p, "
,
m
->
thread_id
,
m
->
thread_idptr
);
bufp
+=
strlen
(
bufp
);
}
...
...
@@ -703,7 +722,8 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
ami_cnt
=
0
;
if
(
!
amip
)
return
;
CRYPTO_THREADID_set
(
&
tid
);
ti
=
amip
->
thread_id
;
tip
=
amip
->
thread_idptr
;
do
{
...
...
@@ -713,8 +733,8 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
ami_cnt
++
;
memset
(
buf
,
'>'
,
ami_cnt
);
BIO_snprintf
(
buf
+
ami_cnt
,
sizeof
buf
-
ami_cnt
,
" thread=%lu, file=%s, line=%d, info=
\"
"
,
CRYPTO_THREADID_hash
(
&
amip
->
threadid
)
,
amip
->
file
,
amip
->
line
);
" thread=%lu
/%p
, file=%s, line=%d, info=
\"
"
,
amip
->
thread_id
,
amip
->
thread_idptr
,
amip
->
file
,
amip
->
line
);
buf_len
=
strlen
(
buf
);
info_len
=
strlen
(
amip
->
info
);
if
(
128
-
buf_len
-
3
<
info_len
)
...
...
@@ -734,7 +754,7 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
amip
=
amip
->
next
;
}
while
(
amip
&&
!
CRYPTO_THREADID_cmp
(
&
amip
->
threadid
,
&
tid
)
);
while
(
amip
&&
amip
->
thread_id
==
ti
&&
amip
->
thread_idptr
==
tip
);
#ifdef LEVITTE_DEBUG_MEM
if
(
amip
)
...
...
crypto/rand/md_rand.c
浏览文件 @
5f834ab1
...
...
@@ -145,7 +145,8 @@ static unsigned int crypto_lock_rand = 0; /* may be set only when a thread
* holds CRYPTO_LOCK_RAND
* (to prevent double locking) */
/* access to lockin_thread is synchronized by CRYPTO_LOCK_RAND2 */
static
CRYPTO_THREADID
locking_tid
;
static
unsigned
long
locking_thread_id
=
0
;
/* valid iff crypto_lock_rand is set */
static
void
*
locking_thread_idptr
=
NULL
;
/* valid iff crypto_lock_rand is set */
#ifdef PREDICT
...
...
@@ -213,10 +214,8 @@ static void ssleay_rand_add(const void *buf, int num, double add)
/* check if we already have the lock */
if
(
crypto_lock_rand
)
{
CRYPTO_THREADID
tid
;
CRYPTO_THREADID_set
(
&
tid
);
CRYPTO_r_lock
(
CRYPTO_LOCK_RAND2
);
do_not_lock
=
!
CRYPTO_THREADID_cmp
(
&
locking_tid
,
&
tid
);
do_not_lock
=
(
locking_thread_id
==
CRYPTO_thread_id
())
&&
(
locking_thread_idptr
==
CRYPTO_thread_idptr
()
);
CRYPTO_r_unlock
(
CRYPTO_LOCK_RAND2
);
}
else
...
...
@@ -374,7 +373,8 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
/* prevent ssleay_rand_bytes() from trying to obtain the lock again */
CRYPTO_w_lock
(
CRYPTO_LOCK_RAND2
);
CRYPTO_THREADID_set
(
&
locking_tid
);
locking_thread_id
=
CRYPTO_thread_id
();
locking_thread_idptr
=
CRYPTO_thread_idptr
();
CRYPTO_w_unlock
(
CRYPTO_LOCK_RAND2
);
crypto_lock_rand
=
1
;
...
...
@@ -536,10 +536,8 @@ static int ssleay_rand_status(void)
* (could happen if a RAND_poll() implementation calls RAND_status()) */
if
(
crypto_lock_rand
)
{
CRYPTO_THREADID
tid
;
CRYPTO_THREADID_set
(
&
tid
);
CRYPTO_r_lock
(
CRYPTO_LOCK_RAND2
);
do_not_lock
=
!
CRYPTO_THREADID_cmp
(
&
locking_tid
,
&
tid
);
do_not_lock
=
(
locking_thread_id
==
CRYPTO_thread_id
())
&&
(
locking_thread_idptr
==
CRYPTO_thread_idptr
()
);
CRYPTO_r_unlock
(
CRYPTO_LOCK_RAND2
);
}
else
...
...
@@ -551,7 +549,8 @@ static int ssleay_rand_status(void)
/* prevent ssleay_rand_bytes() from trying to obtain the lock again */
CRYPTO_w_lock
(
CRYPTO_LOCK_RAND2
);
CRYPTO_THREADID_set
(
&
locking_tid
);
locking_thread_id
=
CRYPTO_thread_id
();
locking_thread_idptr
=
CRYPTO_thread_idptr
();
CRYPTO_w_unlock
(
CRYPTO_LOCK_RAND2
);
crypto_lock_rand
=
1
;
}
...
...
crypto/rsa/rsa_eay.c
浏览文件 @
5f834ab1
...
...
@@ -263,10 +263,8 @@ err:
static
BN_BLINDING
*
rsa_get_blinding
(
RSA
*
rsa
,
int
*
local
,
BN_CTX
*
ctx
)
{
BN_BLINDING
*
ret
;
CRYPTO_THREADID
tid
;
int
got_write_lock
=
0
;
CRYPTO_THREADID_set
(
&
tid
);
CRYPTO_r_lock
(
CRYPTO_LOCK_RSA
);
if
(
rsa
->
blinding
==
NULL
)
...
...
@@ -283,7 +281,7 @@ static BN_BLINDING *rsa_get_blinding(RSA *rsa, int *local, BN_CTX *ctx)
if
(
ret
==
NULL
)
goto
err
;
if
(
!
BN_BLINDING_cmp_thread
(
ret
,
&
tid
))
if
(
(
BN_BLINDING_get_thread_id
(
ret
)
==
CRYPTO_thread_id
())
&&
(
BN_BLINDING_get_thread_idptr
(
ret
)
==
CRYPTO_thread_idptr
()
))
{
/* rsa->blinding is ours! */
...
...
crypto/rsa/rsa_lib.c
浏览文件 @
5f834ab1
...
...
@@ -417,7 +417,8 @@ BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *in_ctx)
RSAerr
(
RSA_F_RSA_SETUP_BLINDING
,
ERR_R_BN_LIB
);
goto
err
;
}
BN_BLINDING_set_thread
(
ret
);
BN_BLINDING_set_thread_id
(
ret
,
CRYPTO_thread_id
());
BN_BLINDING_set_thread_idptr
(
ret
,
CRYPTO_thread_idptr
());
err:
BN_CTX_end
(
ctx
);
if
(
in_ctx
==
NULL
)
...
...
crypto/rsa/rsa_test.c
浏览文件 @
5f834ab1
...
...
@@ -328,7 +328,7 @@ int main(int argc, char *argv[])
}
CRYPTO_cleanup_all_ex_data
();
ERR_remove_
thread_state
(
NULL
);
ERR_remove_
state
(
0
);
CRYPTO_mem_leaks_fp
(
stderr
);
...
...
doc/crypto/BN_BLINDING_new.pod
浏览文件 @
5f834ab1
...
...
@@ -4,7 +4,7 @@
BN_BLINDING_new, BN_BLINDING_free, BN_BLINDING_update, BN_BLINDING_convert,
BN_BLINDING_invert, BN_BLINDING_convert_ex, BN_BLINDING_invert_ex,
BN_BLINDING_
set_thread, BN_BLINDING_cmp_threa
d, BN_BLINDING_get_flags,
BN_BLINDING_
get_thread_id, BN_BLINDING_set_thread_i
d, BN_BLINDING_get_flags,
BN_BLINDING_set_flags, BN_BLINDING_create_param - blinding related BIGNUM
functions.
...
...
@@ -22,10 +22,8 @@ functions.
BN_CTX *ctx);
int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b,
BN_CTX *ctx);
void BN_BLINDING_set_thread(BN_BLINDING *);
int BN_BLINDING_cmp_thread(const BN_BLINDING *,
const CRYPTO_THREADID *);
unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);
void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);
unsigned long BN_BLINDING_get_flags(const BN_BLINDING *);
void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);
BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
...
...
@@ -56,10 +54,11 @@ BN_BLINDING_convert() and BN_BLINDING_invert() are wrapper
functions for BN_BLINDING_convert_ex() and BN_BLINDING_invert_ex()
with B<r> set to NULL.
BN_BLINDING_set_thread() and BN_BLINDING_cmp_thread()
set and compare the "thread id" of the B<BN_BLINDING> structure,
allowing users of the B<BN_BLINDING> structure to
provide proper locking if needed for multi-threaded use.
BN_BLINDING_set_thread_id() and BN_BLINDING_get_thread_id()
set and get the "thread id" value of the B<BN_BLINDING> structure,
a field provided to users of B<BN_BLINDING> structure to help them
provide proper locking if needed for multi-threaded use. The
"thread id" of a newly allocated B<BN_BLINDING> structure is zero.
BN_BLINDING_get_flags() returns the BN_BLINDING flags. Currently
there are two supported flags: B<BN_BLINDING_NO_UPDATE> and
...
...
@@ -86,12 +85,6 @@ success and 0 if an error occured.
BN_BLINDING_get_thread_id() returns the thread id (a B<unsigned long>
value) or 0 if not set.
BN_BLINDING_cmp_thread() returns 0 if the thread id associated with the
B<BN_BLINDING> structure equals the provided thread id (which can be
obtained by CRYPTO_THREADID_set()), otherwise it returns -1 or +1
to indicate the thread ids are different (if the target architecture
supports ordering of thread ids, this follows the traditional "cmp"
semantics of memcmp() or strcmp()).
BN_BLINDING_get_flags() returns the currently set B<BN_BLINDING> flags
(a B<unsigned long> value).
...
...
@@ -109,14 +102,6 @@ BN_BLINDING_convert_ex, BN_BLINDIND_invert_ex, BN_BLINDING_get_thread_id,
BN_BLINDING_set_thread_id, BN_BLINDING_set_flags, BN_BLINDING_get_flags
and BN_BLINDING_create_param were first introduced in OpenSSL 0.9.8
BN_BLINDING_get_thread_idptr, BN_BLINDING_set_thread_idptr were first
introduced in OpenSSL 0.9.9
BN_BLINDING_get_thread_id, BN_BLINDING_set_thread_id,
BN_BLINDING_get_thread_idptr, BN_BLINDING_set_thread_idptr were all
deprecated in favour of BN_BLINDING_set_thread, BN_BLINDING_cmp_thread
which were introduced in OpenSSL 0.9.9
=head1 AUTHOR
Nils Larsch for the OpenSSL project (http://www.openssl.org).
...
...
doc/crypto/bn.pod
浏览文件 @
5f834ab1
...
...
@@ -131,10 +131,8 @@ bn - multiprecision integer arithmetics
BN_CTX *ctx);
int BN_BLINDING_invert_ex(BIGNUM *n,const BIGNUM *r,BN_BLINDING *b,
BN_CTX *ctx);
void BN_BLINDING_set_thread(BN_BLINDING *);
int BN_BLINDING_cmp_thread(const BN_BLINDING *,
const CRYPTO_THREADID *);
unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);
void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);
unsigned long BN_BLINDING_get_flags(const BN_BLINDING *);
void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);
BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
...
...
doc/crypto/threads.pod
浏览文件 @
5f834ab1
...
...
@@ -76,7 +76,9 @@ below).
idptr_function(void) is a function that similarly returns a thread ID,
but of type void *. This is not needed on platforms where &errno is
different for each thread.
different for each thread. OpenSSL assumes that it is in the same
thread iff both the numerical and the pointer thread ID agree, so it
suffices to define one of these two callback functions appropriately.
Additionally, OpenSSL supports dynamic locks, and sometimes, some parts
of OpenSSL need it for better performance. To enable this, the following
...
...
@@ -164,9 +166,7 @@ There is still the issue of platforms where pthread_self() returns
something other than an integer. It is for cases like this that
CRYPTO_set_idptr_callback() comes in handy. (E.g., call malloc(1)
once in each thread, and have idptr_function() return a pointer to
this object.) Note that if neither id_function() or idptr_function()
are provided, OpenSSL will use (&errno) as a fallback (as this
usually returns a unique address for each thread).
this object.)
=head1 EXAMPLES
...
...
ssl/ssltest.c
浏览文件 @
5f834ab1
...
...
@@ -1014,7 +1014,7 @@ end:
#endif
CRYPTO_cleanup_all_ex_data
();
ERR_free_strings
();
ERR_remove_
thread_state
(
NULL
);
ERR_remove_
state
(
0
);
EVP_cleanup
();
CRYPTO_mem_leaks
(
bio_err
);
if
(
bio_err
!=
NULL
)
BIO_free
(
bio_err
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录