Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
18e377b4
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
1 年多 前同步成功
通知
10
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看板
提交
18e377b4
编写于
3月 22, 2006
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make EVP_PKEY_ASN1_METHOD opaque. Add application level functions to
initialize it. Initial support for application added public key ASN1.
上级
043b2e9c
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
179 addition
and
55 deletion
+179
-55
crypto/Makefile
crypto/Makefile
+1
-1
crypto/asn1/ameth_lib.c
crypto/asn1/ameth_lib.c
+125
-3
crypto/asn1/asn1.h
crypto/asn1/asn1.h
+0
-36
crypto/asn1/asn1_locl.h
crypto/asn1/asn1_locl.h
+37
-0
crypto/asn1/d2i_pr.c
crypto/asn1/d2i_pr.c
+1
-1
crypto/asn1/x_pubkey.c
crypto/asn1/x_pubkey.c
+3
-2
crypto/dh/dh_ameth.c
crypto/dh/dh_ameth.c
+1
-0
crypto/dsa/dsa_ameth.c
crypto/dsa/dsa_ameth.c
+1
-0
crypto/ec/ec_ameth.c
crypto/ec/ec_ameth.c
+1
-0
crypto/evp/evp.h
crypto/evp/evp.h
+1
-1
crypto/evp/evp_pkey.c
crypto/evp/evp_pkey.c
+3
-9
crypto/evp/p_lib.c
crypto/evp/p_lib.c
+4
-2
crypto/rsa/rsa_ameth.c
crypto/rsa/rsa_ameth.c
+1
-0
未找到文件。
crypto/Makefile
浏览文件 @
18e377b4
...
...
@@ -7,7 +7,7 @@ TOP= ..
CC
=
cc
INCLUDE
=
-I
.
-I
$(TOP)
-I
../include
# INCLUDES targets sudbirs!
INCLUDES
=
-I
..
-I
../..
-I
../../include
INCLUDES
=
-I
..
-I
../..
-I
../
asn1
-I
../
../include
CFLAG
=
-g
MAKEDEPPROG
=
makedepend
MAKEDEPEND
=
$(TOP)
/util/domd
$(TOP)
-MD
$(MAKEDEPPROG)
...
...
crypto/asn1/ameth_lib.c
浏览文件 @
18e377b4
...
...
@@ -81,6 +81,11 @@ const EVP_PKEY_ASN1_METHOD *standard_methods[] =
&
eckey_asn1_meth
};
typedef
int
sk_cmp_fn_type
(
const
char
*
const
*
a
,
const
char
*
const
*
b
);
static
STACK
*
app_methods
=
NULL
;
#ifdef TEST
void
main
()
{
...
...
@@ -97,14 +102,21 @@ void main()
static
int
ameth_cmp
(
const
EVP_PKEY_ASN1_METHOD
*
const
*
a
,
const
EVP_PKEY_ASN1_METHOD
*
const
*
b
)
{
/*fprintf(stderr, "Comparing %d with %d\n", (*a)->pkey_id, (*b)->pkey_id);*/
return
((
*
a
)
->
pkey_id
-
(
*
b
)
->
pkey_id
);
}
const
EVP_PKEY_ASN1_METHOD
*
EVP_PKEY_
ASN
1_find
(
int
type
)
const
EVP_PKEY_ASN1_METHOD
*
EVP_PKEY_
asn
1_find
(
int
type
)
{
EVP_PKEY_ASN1_METHOD
tmp
,
*
t
=
&
tmp
,
**
ret
;
tmp
.
pkey_id
=
type
;
if
(
app_methods
)
{
int
idx
;
idx
=
sk_find
(
app_methods
,
(
char
*
)
&
t
);
if
(
idx
>
0
)
return
(
EVP_PKEY_ASN1_METHOD
*
)
sk_value
(
app_methods
,
idx
);
}
ret
=
(
EVP_PKEY_ASN1_METHOD
**
)
OBJ_bsearch
((
char
*
)
&
t
,
(
char
*
)
standard_methods
,
sizeof
(
standard_methods
)
/
sizeof
(
EVP_PKEY_ASN1_METHOD
*
),
...
...
@@ -113,7 +125,117 @@ const EVP_PKEY_ASN1_METHOD *EVP_PKEY_ASN1_find(int type)
if
(
!
ret
||
!*
ret
)
return
NULL
;
if
((
*
ret
)
->
pkey_flags
&
ASN1_PKEY_ALIAS
)
return
EVP_PKEY_
ASN
1_find
((
*
ret
)
->
pkey_base_id
);
return
EVP_PKEY_
asn
1_find
((
*
ret
)
->
pkey_base_id
);
return
*
ret
;
}
int
EVP_PKEY_asn1_add
(
const
EVP_PKEY_ASN1_METHOD
*
ameth
)
{
if
(
app_methods
==
NULL
)
{
app_methods
=
sk_new
((
sk_cmp_fn_type
*
)
ameth_cmp
);
if
(
!
app_methods
)
return
0
;
}
if
(
!
sk_push
(
app_methods
,
(
char
*
)
ameth
))
return
0
;
sk_sort
(
app_methods
);
return
1
;
}
EVP_PKEY_ASN1_METHOD
*
EVP_PKEY_asn1_new
(
int
id
)
{
EVP_PKEY_ASN1_METHOD
*
ameth
;
ameth
=
OPENSSL_malloc
(
sizeof
(
EVP_PKEY_ASN1_METHOD
));
if
(
!
ameth
)
return
NULL
;
ameth
->
pkey_id
=
id
;
ameth
->
pkey_base_id
=
id
;
ameth
->
pkey_flags
=
ASN1_PKEY_DYNAMIC
;
ameth
->
pub_decode
=
0
;
ameth
->
pub_encode
=
0
;
ameth
->
pub_cmp
=
0
;
ameth
->
pub_print
=
0
;
ameth
->
priv_decode
=
0
;
ameth
->
priv_encode
=
0
;
ameth
->
priv_print
=
0
;
ameth
->
pkey_size
=
0
;
ameth
->
pkey_bits
=
0
;
ameth
->
param_decode
=
0
;
ameth
->
param_encode
=
0
;
ameth
->
param_missing
=
0
;
ameth
->
param_copy
=
0
;
ameth
->
param_cmp
=
0
;
ameth
->
param_print
=
0
;
ameth
->
pkey_free
=
0
;
ameth
->
pkey_ctrl
=
0
;
return
ameth
;
}
void
EVP_PKEY_asn1_set_public
(
EVP_PKEY_ASN1_METHOD
*
ameth
,
int
(
*
pub_decode
)(
EVP_PKEY
*
pk
,
X509_PUBKEY
*
pub
),
int
(
*
pub_encode
)(
X509_PUBKEY
*
pub
,
const
EVP_PKEY
*
pk
),
int
(
*
pub_cmp
)(
const
EVP_PKEY
*
a
,
const
EVP_PKEY
*
b
),
int
(
*
pub_print
)(
BIO
*
out
,
const
EVP_PKEY
*
pkey
,
int
indent
,
ASN1_PCTX
*
pctx
),
int
(
*
pkey_size
)(
const
EVP_PKEY
*
pk
),
int
(
*
pkey_bits
)(
const
EVP_PKEY
*
pk
))
{
ameth
->
pub_decode
=
pub_decode
;
ameth
->
pub_encode
=
pub_encode
;
ameth
->
pub_cmp
=
pub_cmp
;
ameth
->
pub_print
=
pub_print
;
ameth
->
pkey_size
=
pkey_size
;
ameth
->
pkey_bits
=
pkey_bits
;
}
void
EVP_PKEY_asn1_set_private
(
EVP_PKEY_ASN1_METHOD
*
ameth
,
int
(
*
priv_decode
)(
EVP_PKEY
*
pk
,
PKCS8_PRIV_KEY_INFO
*
p8inf
),
int
(
*
priv_encode
)(
PKCS8_PRIV_KEY_INFO
*
p8
,
const
EVP_PKEY
*
pk
),
int
(
*
priv_print
)(
BIO
*
out
,
const
EVP_PKEY
*
pkey
,
int
indent
,
ASN1_PCTX
*
pctx
))
{
ameth
->
priv_decode
=
priv_decode
;
ameth
->
priv_encode
=
priv_encode
;
ameth
->
priv_print
=
priv_print
;
}
void
EVP_PKEY_asn1_set_param
(
EVP_PKEY_ASN1_METHOD
*
ameth
,
int
(
*
param_decode
)(
const
EVP_PKEY
*
pk
,
X509_PUBKEY
*
pub
),
int
(
*
param_encode
)(
X509_PUBKEY
*
pub
,
const
EVP_PKEY
*
pk
),
int
(
*
param_missing
)(
const
EVP_PKEY
*
pk
),
int
(
*
param_copy
)(
EVP_PKEY
*
to
,
const
EVP_PKEY
*
from
),
int
(
*
param_cmp
)(
const
EVP_PKEY
*
a
,
const
EVP_PKEY
*
b
),
int
(
*
param_print
)(
BIO
*
out
,
const
EVP_PKEY
*
pkey
,
int
indent
,
ASN1_PCTX
*
pctx
))
{
ameth
->
param_decode
=
param_decode
;
ameth
->
param_encode
=
param_encode
;
ameth
->
param_missing
=
param_missing
;
ameth
->
param_copy
=
param_copy
;
ameth
->
param_cmp
=
param_cmp
;
ameth
->
param_print
=
param_print
;
}
void
EVP_PKEY_asn1_set_free
(
EVP_PKEY_ASN1_METHOD
*
ameth
,
void
(
*
pkey_free
)(
EVP_PKEY
*
pkey
))
{
ameth
->
pkey_free
=
pkey_free
;
}
void
EVP_PKEY_asn1_set_ctrl
(
EVP_PKEY_ASN1_METHOD
*
ameth
,
void
(
*
pkey_ctrl
)(
EVP_PKEY
*
pkey
,
int
op
,
long
arg1
,
void
*
arg2
))
{
ameth
->
pkey_ctrl
=
pkey_ctrl
;
}
crypto/asn1/asn1.h
浏览文件 @
18e377b4
...
...
@@ -282,42 +282,6 @@ typedef struct ASN1_TLC_st ASN1_TLC;
/* This is just an opaque pointer */
typedef
struct
ASN1_VALUE_st
ASN1_VALUE
;
/* ASN1 public key method structure */
#define ASN1_PKEY_ALIAS 0x1
struct
evp_pkey_asn1_method_st
{
int
pkey_id
;
int
pkey_base_id
;
unsigned
long
pkey_flags
;
int
(
*
pub_decode
)(
EVP_PKEY
*
pk
,
X509_PUBKEY
*
pub
);
int
(
*
pub_encode
)(
X509_PUBKEY
*
pub
,
const
EVP_PKEY
*
pk
);
int
(
*
pub_cmp
)(
const
EVP_PKEY
*
a
,
const
EVP_PKEY
*
b
);
int
(
*
pub_print
)(
BIO
*
out
,
const
EVP_PKEY
*
pkey
,
int
indent
,
ASN1_PCTX
*
pctx
);
int
(
*
priv_decode
)(
EVP_PKEY
*
pk
,
PKCS8_PRIV_KEY_INFO
*
p8inf
);
int
(
*
priv_encode
)(
PKCS8_PRIV_KEY_INFO
*
p8
,
const
EVP_PKEY
*
pk
);
int
(
*
priv_print
)(
BIO
*
out
,
const
EVP_PKEY
*
pkey
,
int
indent
,
ASN1_PCTX
*
pctx
);
int
(
*
pkey_size
)(
const
EVP_PKEY
*
pk
);
int
(
*
pkey_bits
)(
const
EVP_PKEY
*
pk
);
int
(
*
param_decode
)(
const
EVP_PKEY
*
pk
,
X509_PUBKEY
*
pub
);
int
(
*
param_encode
)(
X509_PUBKEY
*
pub
,
const
EVP_PKEY
*
pk
);
int
(
*
param_missing
)(
const
EVP_PKEY
*
pk
);
int
(
*
param_copy
)(
EVP_PKEY
*
to
,
const
EVP_PKEY
*
from
);
int
(
*
param_cmp
)(
const
EVP_PKEY
*
a
,
const
EVP_PKEY
*
b
);
int
(
*
param_print
)(
BIO
*
out
,
const
EVP_PKEY
*
pkey
,
int
indent
,
ASN1_PCTX
*
pctx
);
void
(
*
pkey_free
)(
EVP_PKEY
*
pkey
);
void
(
*
pkey_ctrl
)(
EVP_PKEY
*
pkey
,
int
op
,
long
arg1
,
void
*
arg2
);
}
/* EVP_PKEY_ASN1_METHOD */
;
/* Declare ASN1 functions: the implement macro in in asn1t.h */
#define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)
...
...
crypto/asn1/asn1_locl.h
浏览文件 @
18e377b4
...
...
@@ -68,3 +68,40 @@ struct asn1_pctx_st
unsigned
long
oid_flags
;
unsigned
long
str_flags
;
}
/* ASN1_PCTX */
;
/* ASN1 public key method structure */
#define ASN1_PKEY_ALIAS 0x1
#define ASN1_PKEY_DYNAMIC 0x2
struct
evp_pkey_asn1_method_st
{
int
pkey_id
;
int
pkey_base_id
;
unsigned
long
pkey_flags
;
int
(
*
pub_decode
)(
EVP_PKEY
*
pk
,
X509_PUBKEY
*
pub
);
int
(
*
pub_encode
)(
X509_PUBKEY
*
pub
,
const
EVP_PKEY
*
pk
);
int
(
*
pub_cmp
)(
const
EVP_PKEY
*
a
,
const
EVP_PKEY
*
b
);
int
(
*
pub_print
)(
BIO
*
out
,
const
EVP_PKEY
*
pkey
,
int
indent
,
ASN1_PCTX
*
pctx
);
int
(
*
priv_decode
)(
EVP_PKEY
*
pk
,
PKCS8_PRIV_KEY_INFO
*
p8inf
);
int
(
*
priv_encode
)(
PKCS8_PRIV_KEY_INFO
*
p8
,
const
EVP_PKEY
*
pk
);
int
(
*
priv_print
)(
BIO
*
out
,
const
EVP_PKEY
*
pkey
,
int
indent
,
ASN1_PCTX
*
pctx
);
int
(
*
pkey_size
)(
const
EVP_PKEY
*
pk
);
int
(
*
pkey_bits
)(
const
EVP_PKEY
*
pk
);
int
(
*
param_decode
)(
const
EVP_PKEY
*
pk
,
X509_PUBKEY
*
pub
);
int
(
*
param_encode
)(
X509_PUBKEY
*
pub
,
const
EVP_PKEY
*
pk
);
int
(
*
param_missing
)(
const
EVP_PKEY
*
pk
);
int
(
*
param_copy
)(
EVP_PKEY
*
to
,
const
EVP_PKEY
*
from
);
int
(
*
param_cmp
)(
const
EVP_PKEY
*
a
,
const
EVP_PKEY
*
b
);
int
(
*
param_print
)(
BIO
*
out
,
const
EVP_PKEY
*
pkey
,
int
indent
,
ASN1_PCTX
*
pctx
);
void
(
*
pkey_free
)(
EVP_PKEY
*
pkey
);
void
(
*
pkey_ctrl
)(
EVP_PKEY
*
pkey
,
int
op
,
long
arg1
,
void
*
arg2
);
}
/* EVP_PKEY_ASN1_METHOD */
;
crypto/asn1/d2i_pr.c
浏览文件 @
18e377b4
...
...
@@ -89,7 +89,7 @@ EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
ret
->
save_type
=
type
;
ret
->
type
=
EVP_PKEY_type
(
type
);
ret
->
ameth
=
EVP_PKEY_
ASN
1_find
(
type
);
ret
->
ameth
=
EVP_PKEY_
asn
1_find
(
type
);
switch
(
ret
->
type
)
{
#ifndef OPENSSL_NO_RSA
...
...
crypto/asn1/x_pubkey.c
浏览文件 @
18e377b4
...
...
@@ -60,6 +60,7 @@
#include "cryptlib.h"
#include <openssl/asn1t.h>
#include <openssl/x509.h>
#include "asn1_locl.h"
#ifndef OPENSSL_NO_RSA
#include <openssl/rsa.h>
#endif
...
...
@@ -95,7 +96,7 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
if
((
pk
=
X509_PUBKEY_new
())
==
NULL
)
goto
error
;
meth
=
EVP_PKEY_
ASN
1_find
(
pkey
->
type
);
meth
=
EVP_PKEY_
asn
1_find
(
pkey
->
type
);
if
(
meth
)
{
...
...
@@ -153,7 +154,7 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
goto
error
;
}
meth
=
EVP_PKEY_
ASN
1_find
(
OBJ_obj2nid
(
key
->
algor
->
algorithm
));
meth
=
EVP_PKEY_
asn
1_find
(
OBJ_obj2nid
(
key
->
algor
->
algorithm
));
if
(
meth
)
{
...
...
crypto/dh/dh_ameth.c
浏览文件 @
18e377b4
...
...
@@ -60,6 +60,7 @@
#include <openssl/x509.h>
#include <openssl/asn1.h>
#include <openssl/dh.h>
#include "asn1_locl.h"
static
void
int_dh_free
(
EVP_PKEY
*
pkey
)
{
...
...
crypto/dsa/dsa_ameth.c
浏览文件 @
18e377b4
...
...
@@ -60,6 +60,7 @@
#include <openssl/x509.h>
#include <openssl/asn1.h>
#include <openssl/dsa.h>
#include "asn1_locl.h"
static
int
dsa_pub_decode
(
EVP_PKEY
*
pkey
,
X509_PUBKEY
*
pubkey
)
{
...
...
crypto/ec/ec_ameth.c
浏览文件 @
18e377b4
...
...
@@ -59,6 +59,7 @@
#include "cryptlib.h"
#include <openssl/x509.h>
#include <openssl/ec.h>
#include "asn1_locl.h"
static
int
eckey_param2type
(
int
*
pptype
,
void
**
ppval
,
EC_KEY
*
ec_key
)
{
...
...
crypto/evp/evp.h
浏览文件 @
18e377b4
...
...
@@ -855,7 +855,7 @@ int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
EVP_PBE_KEYGEN
*
keygen
);
void
EVP_PBE_cleanup
(
void
);
const
EVP_PKEY_ASN1_METHOD
*
EVP_PKEY_
ASN
1_find
(
int
type
);
const
EVP_PKEY_ASN1_METHOD
*
EVP_PKEY_
asn
1_find
(
int
type
);
/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
...
...
crypto/evp/evp_pkey.c
浏览文件 @
18e377b4
...
...
@@ -61,13 +61,7 @@
#include "cryptlib.h"
#include <openssl/x509.h>
#include <openssl/rand.h>
#ifndef OPENSSL_NO_RSA
#include <openssl/rsa.h>
#endif
#ifndef OPENSSL_NO_DSA
#include <openssl/dsa.h>
#endif
#include <openssl/bn.h>
#include "asn1_locl.h"
/* Extract a private key from a PKCS8 structure */
...
...
@@ -86,7 +80,7 @@ EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8)
return
NULL
;
}
meth
=
EVP_PKEY_
ASN
1_find
(
OBJ_obj2nid
(
algoid
));
meth
=
EVP_PKEY_
asn
1_find
(
OBJ_obj2nid
(
algoid
));
if
(
meth
)
{
...
...
@@ -138,7 +132,7 @@ PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken)
}
p8
->
broken
=
broken
;
meth
=
EVP_PKEY_
ASN
1_find
(
pkey
->
type
);
meth
=
EVP_PKEY_
asn
1_find
(
pkey
->
type
);
if
(
meth
)
{
...
...
crypto/evp/p_lib.c
浏览文件 @
18e377b4
...
...
@@ -74,6 +74,8 @@
#include <openssl/dh.h>
#endif
#include "asn1_locl.h"
static
void
EVP_PKEY_free_it
(
EVP_PKEY
*
x
);
int
EVP_PKEY_bits
(
EVP_PKEY
*
pkey
)
...
...
@@ -189,7 +191,7 @@ int EVP_PKEY_assign(EVP_PKEY *pkey, int type, char *key)
if
(
pkey
==
NULL
)
return
(
0
);
if
(
pkey
->
pkey
.
ptr
!=
NULL
)
EVP_PKEY_free_it
(
pkey
);
ameth
=
EVP_PKEY_
ASN
1_find
(
type
);
ameth
=
EVP_PKEY_
asn
1_find
(
type
);
pkey
->
ameth
=
ameth
;
pkey
->
type
=
ameth
->
pkey_id
;
pkey
->
save_type
=
type
;
...
...
@@ -284,7 +286,7 @@ DH *EVP_PKEY_get1_DH(EVP_PKEY *pkey)
int
EVP_PKEY_type
(
int
type
)
{
const
EVP_PKEY_ASN1_METHOD
*
ameth
;
ameth
=
EVP_PKEY_
ASN
1_find
(
type
);
ameth
=
EVP_PKEY_
asn
1_find
(
type
);
if
(
ameth
)
return
ameth
->
pkey_id
;
return
NID_undef
;
...
...
crypto/rsa/rsa_ameth.c
浏览文件 @
18e377b4
...
...
@@ -60,6 +60,7 @@
#include <openssl/asn1t.h>
#include <openssl/x509.h>
#include <openssl/rsa.h>
#include "asn1_locl.h"
static
int
rsa_pub_encode
(
X509_PUBKEY
*
pk
,
const
EVP_PKEY
*
pkey
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录