Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
openssl
提交
f733a5ef
O
openssl
项目概览
btwise
/
openssl
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f733a5ef
编写于
4月 07, 2006
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Initial functions for main EVP_PKEY_METHOD operations.
No method implementations yet.
上级
5da98aa6
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
284 addition
and
15 deletion
+284
-15
CHANGES
CHANGES
+5
-0
crypto/evp/Makefile
crypto/evp/Makefile
+2
-2
crypto/evp/evp.h
crypto/evp/evp.h
+12
-2
crypto/evp/evp_err.c
crypto/evp/evp_err.c
+13
-3
crypto/evp/evp_locl.h
crypto/evp/evp_locl.h
+1
-0
crypto/evp/p_dec.c
crypto/evp/p_dec.c
+1
-1
crypto/evp/p_enc.c
crypto/evp/p_enc.c
+1
-1
crypto/evp/p_open.c
crypto/evp/p_open.c
+1
-1
crypto/evp/p_seal.c
crypto/evp/p_seal.c
+1
-1
crypto/evp/pmeth_fn.c
crypto/evp/pmeth_fn.c
+235
-0
crypto/evp/pmeth_lib.c
crypto/evp/pmeth_lib.c
+9
-1
crypto/pkcs7/pk7_doit.c
crypto/pkcs7/pk7_doit.c
+3
-3
未找到文件。
CHANGES
浏览文件 @
f733a5ef
...
...
@@ -4,6 +4,11 @@
Changes between 0.9.8a and 0.9.9 [xx XXX xxxx]
*) Add functions for main EVP_PKEY_method operations. The undocumented
functions EVP_PKEY_{encrypt,decrypt} have been renamed to
EVP_PKEY_{encrypt,decrypt}_old.
[Steve Henson]
*) Initial definitions for EVP_PKEY_METHOD. This will be a high level public
key API, doesn't do much yet.
[Steve Henson]
...
...
crypto/evp/Makefile
浏览文件 @
f733a5ef
...
...
@@ -28,7 +28,7 @@ LIBSRC= encode.c digest.c evp_enc.c evp_key.c evp_acnf.c \
bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c
\
c_all.c c_allc.c c_alld.c evp_lib.c bio_ok.c
\
evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c
\
e_old.c pmeth_lib.c
e_old.c pmeth_lib.c
pmeth_fn.c
LIBOBJ
=
encode.o digest.o evp_enc.o evp_key.o evp_acnf.o
\
e_des.o e_bf.o e_idea.o e_des3.o
\
...
...
@@ -40,7 +40,7 @@ LIBOBJ= encode.o digest.o evp_enc.o evp_key.o evp_acnf.o \
bio_md.o bio_b64.o bio_enc.o evp_err.o e_null.o
\
c_all.o c_allc.o c_alld.o evp_lib.o bio_ok.o
\
evp_pkey.o evp_pbe.o p5_crpt.o p5_crpt2.o
\
e_old.o pmeth_lib.o
e_old.o pmeth_lib.o
pmeth_fn.o
SRC
=
$(LIBSRC)
...
...
crypto/evp/evp.h
浏览文件 @
f733a5ef
...
...
@@ -768,10 +768,10 @@ const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
const
EVP_MD
*
EVP_get_digestbyname
(
const
char
*
name
);
void
EVP_cleanup
(
void
);
int
EVP_PKEY_decrypt
(
unsigned
char
*
dec_key
,
int
EVP_PKEY_decrypt
_old
(
unsigned
char
*
dec_key
,
const
unsigned
char
*
enc_key
,
int
enc_key_len
,
EVP_PKEY
*
private_key
);
int
EVP_PKEY_encrypt
(
unsigned
char
*
enc_key
,
int
EVP_PKEY_encrypt
_old
(
unsigned
char
*
enc_key
,
const
unsigned
char
*
key
,
int
key_len
,
EVP_PKEY
*
pub_key
);
int
EVP_PKEY_type
(
int
type
);
...
...
@@ -943,13 +943,21 @@ void ERR_load_EVP_strings(void);
#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103
#define EVP_F_EVP_PKEY_CTX_CTRL 137
#define EVP_F_EVP_PKEY_DECRYPT 104
#define EVP_F_EVP_PKEY_DECRYPT_INIT 138
#define EVP_F_EVP_PKEY_ENCRYPT 105
#define EVP_F_EVP_PKEY_ENCRYPT_INIT 139
#define EVP_F_EVP_PKEY_GET1_DH 119
#define EVP_F_EVP_PKEY_GET1_DSA 120
#define EVP_F_EVP_PKEY_GET1_ECDSA 130
#define EVP_F_EVP_PKEY_GET1_EC_KEY 131
#define EVP_F_EVP_PKEY_GET1_RSA 121
#define EVP_F_EVP_PKEY_NEW 106
#define EVP_F_EVP_PKEY_SIGN 140
#define EVP_F_EVP_PKEY_SIGN_INIT 141
#define EVP_F_EVP_PKEY_VERIFY 142
#define EVP_F_EVP_PKEY_VERIFY_INIT 143
#define EVP_F_EVP_PKEY_VERIFY_RECOVER 144
#define EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT 145
#define EVP_F_EVP_RIJNDAEL 126
#define EVP_F_EVP_SIGNFINAL 107
#define EVP_F_EVP_VERIFYFINAL 108
...
...
@@ -995,6 +1003,8 @@ void ERR_load_EVP_strings(void);
#define EVP_R_NO_OPERATION_SET 149
#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104
#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105
#define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 150
#define EVP_R_OPERATON_NOT_INITIALIZED 151
#define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117
#define EVP_R_PRIVATE_KEY_DECODE_ERROR 145
#define EVP_R_PRIVATE_KEY_ENCODE_ERROR 146
...
...
crypto/evp/evp_err.c
浏览文件 @
f733a5ef
...
...
@@ -90,15 +90,23 @@ static ERR_STRING_DATA EVP_str_functs[]=
{
ERR_FUNC
(
EVP_F_EVP_PKCS82PKEY_BROKEN
),
"EVP_PKCS82PKEY_BROKEN"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY2PKCS8_BROKEN
),
"EVP_PKEY2PKCS8_broken"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_COPY_PARAMETERS
),
"EVP_PKEY_copy_parameters"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_CTX_CTRL
),
"EVP_PKEY_CTX_CTRL"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_DECRYPT
),
"EVP_PKEY_decrypt"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_ENCRYPT
),
"EVP_PKEY_encrypt"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_CTX_CTRL
),
"EVP_PKEY_CTX_ctrl"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_DECRYPT
),
"EVP_PKEY_DECRYPT"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_DECRYPT_INIT
),
"EVP_PKEY_DECRYPT_INIT"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_ENCRYPT
),
"EVP_PKEY_ENCRYPT"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_ENCRYPT_INIT
),
"EVP_PKEY_ENCRYPT_INIT"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_GET1_DH
),
"EVP_PKEY_get1_DH"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_GET1_DSA
),
"EVP_PKEY_get1_DSA"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_GET1_ECDSA
),
"EVP_PKEY_GET1_ECDSA"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_GET1_EC_KEY
),
"EVP_PKEY_get1_EC_KEY"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_GET1_RSA
),
"EVP_PKEY_get1_RSA"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_NEW
),
"EVP_PKEY_new"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_SIGN
),
"EVP_PKEY_SIGN"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_SIGN_INIT
),
"EVP_PKEY_SIGN_INIT"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_VERIFY
),
"EVP_PKEY_VERIFY"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_VERIFY_INIT
),
"EVP_PKEY_VERIFY_INIT"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_VERIFY_RECOVER
),
"EVP_PKEY_VERIFY_RECOVER"
},
{
ERR_FUNC
(
EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT
),
"EVP_PKEY_VERIFY_RECOVER_INIT"
},
{
ERR_FUNC
(
EVP_F_EVP_RIJNDAEL
),
"EVP_RIJNDAEL"
},
{
ERR_FUNC
(
EVP_F_EVP_SIGNFINAL
),
"EVP_SignFinal"
},
{
ERR_FUNC
(
EVP_F_EVP_VERIFYFINAL
),
"EVP_VerifyFinal"
},
...
...
@@ -147,6 +155,8 @@ static ERR_STRING_DATA EVP_str_reasons[]=
{
ERR_REASON
(
EVP_R_NO_OPERATION_SET
)
,
"no operation set"
},
{
ERR_REASON
(
EVP_R_NO_SIGN_FUNCTION_CONFIGURED
),
"no sign function configured"
},
{
ERR_REASON
(
EVP_R_NO_VERIFY_FUNCTION_CONFIGURED
),
"no verify function configured"
},
{
ERR_REASON
(
EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE
),
"operation not supported for this keytype"
},
{
ERR_REASON
(
EVP_R_OPERATON_NOT_INITIALIZED
),
"operaton not initialized"
},
{
ERR_REASON
(
EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE
),
"pkcs8 unknown broken type"
},
{
ERR_REASON
(
EVP_R_PRIVATE_KEY_DECODE_ERROR
),
"private key decode error"
},
{
ERR_REASON
(
EVP_R_PRIVATE_KEY_ENCODE_ERROR
),
"private key encode error"
},
...
...
crypto/evp/evp_locl.h
浏览文件 @
f733a5ef
...
...
@@ -264,6 +264,7 @@ struct evp_pkey_method_st
int
pkey_id
;
int
flags
;
int
(
*
init
)(
EVP_PKEY_CTX
*
ctx
);
int
(
*
paramgen_init
)(
EVP_PKEY_CTX
*
ctx
);
int
(
*
paramgen
)(
EVP_PKEY
*
key
,
EVP_PKEY_CTX
*
ctx
);
...
...
crypto/evp/p_dec.c
浏览文件 @
f733a5ef
...
...
@@ -66,7 +66,7 @@
#include <openssl/objects.h>
#include <openssl/x509.h>
int
EVP_PKEY_decrypt
(
unsigned
char
*
key
,
const
unsigned
char
*
ek
,
int
ekl
,
int
EVP_PKEY_decrypt
_old
(
unsigned
char
*
key
,
const
unsigned
char
*
ek
,
int
ekl
,
EVP_PKEY
*
priv
)
{
int
ret
=
-
1
;
...
...
crypto/evp/p_enc.c
浏览文件 @
f733a5ef
...
...
@@ -66,7 +66,7 @@
#include <openssl/objects.h>
#include <openssl/x509.h>
int
EVP_PKEY_encrypt
(
unsigned
char
*
ek
,
const
unsigned
char
*
key
,
int
key_len
,
int
EVP_PKEY_encrypt
_old
(
unsigned
char
*
ek
,
const
unsigned
char
*
key
,
int
key_len
,
EVP_PKEY
*
pubk
)
{
int
ret
=
0
;
...
...
crypto/evp/p_open.c
浏览文件 @
f733a5ef
...
...
@@ -95,7 +95,7 @@ int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
goto
err
;
}
i
=
EVP_PKEY_decrypt
(
key
,
ek
,
ekl
,
priv
);
i
=
EVP_PKEY_decrypt
_old
(
key
,
ek
,
ekl
,
priv
);
if
((
i
<=
0
)
||
!
EVP_CIPHER_CTX_set_key_length
(
ctx
,
i
))
{
/* ERROR */
...
...
crypto/evp/p_seal.c
浏览文件 @
f733a5ef
...
...
@@ -87,7 +87,7 @@ int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek
for
(
i
=
0
;
i
<
npubk
;
i
++
)
{
ekl
[
i
]
=
EVP_PKEY_encrypt
(
ek
[
i
],
key
,
EVP_CIPHER_CTX_key_length
(
ctx
),
ekl
[
i
]
=
EVP_PKEY_encrypt
_old
(
ek
[
i
],
key
,
EVP_CIPHER_CTX_key_length
(
ctx
),
pubk
[
i
]);
if
(
ekl
[
i
]
<=
0
)
return
(
-
1
);
}
...
...
crypto/evp/pmeth_fn.c
0 → 100644
浏览文件 @
f733a5ef
/* pmeth_fn.c */
/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
* project 2006.
*/
/* ====================================================================
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* licensing@OpenSSL.org.
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This product includes cryptographic software written by Eric Young
* (eay@cryptsoft.com). This product includes software written by Tim
* Hudson (tjh@cryptsoft.com).
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <openssl/objects.h>
#include "cryptlib.h"
#include <openssl/evp.h>
#include "evp_locl.h"
int
EVP_PKEY_sign_init
(
EVP_PKEY_CTX
*
ctx
,
EVP_PKEY
*
pkey
)
{
int
ret
;
if
(
!
ctx
||
!
ctx
->
pmeth
||
!
ctx
->
pmeth
->
sign_init
)
{
EVPerr
(
EVP_F_EVP_PKEY_SIGN_INIT
,
EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE
);
return
-
2
;
}
ctx
->
operation
=
EVP_PKEY_OP_SIGN
;
ret
=
ctx
->
pmeth
->
sign_init
(
ctx
,
pkey
);
if
(
ret
<=
0
)
ctx
->
operation
=
EVP_PKEY_OP_UNDEFINED
;
return
ret
;
}
int
EVP_PKEY_sign
(
EVP_PKEY_CTX
*
ctx
,
unsigned
char
*
sig
,
int
*
siglen
,
unsigned
char
*
tbs
,
int
tbslen
)
{
if
(
!
ctx
||
!
ctx
->
pmeth
||
!
ctx
->
pmeth
->
sign
)
{
EVPerr
(
EVP_F_EVP_PKEY_SIGN
,
EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE
);
return
-
2
;
}
if
(
ctx
->
operation
!=
EVP_PKEY_OP_SIGN
)
{
EVPerr
(
EVP_F_EVP_PKEY_SIGN
,
EVP_R_OPERATON_NOT_INITIALIZED
);
return
-
1
;
}
return
ctx
->
pmeth
->
sign
(
ctx
,
sig
,
siglen
,
tbs
,
tbslen
);
}
int
EVP_PKEY_verify_init
(
EVP_PKEY_CTX
*
ctx
,
EVP_PKEY
*
pkey
)
{
int
ret
;
if
(
!
ctx
||
!
ctx
->
pmeth
||
!
ctx
->
pmeth
->
verify_init
)
{
EVPerr
(
EVP_F_EVP_PKEY_VERIFY_INIT
,
EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE
);
return
-
2
;
}
ctx
->
operation
=
EVP_PKEY_OP_VERIFY
;
ret
=
ctx
->
pmeth
->
verify_init
(
ctx
,
pkey
);
if
(
ret
<=
0
)
ctx
->
operation
=
EVP_PKEY_OP_UNDEFINED
;
return
ret
;
}
int
EVP_PKEY_verify
(
EVP_PKEY_CTX
*
ctx
,
unsigned
char
*
sig
,
int
siglen
,
unsigned
char
*
tbs
,
int
tbslen
)
{
if
(
!
ctx
||
!
ctx
->
pmeth
||
!
ctx
->
pmeth
->
verify
)
{
EVPerr
(
EVP_F_EVP_PKEY_VERIFY
,
EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE
);
return
-
2
;
}
if
(
ctx
->
operation
!=
EVP_PKEY_OP_VERIFY
)
{
EVPerr
(
EVP_F_EVP_PKEY_VERIFY
,
EVP_R_OPERATON_NOT_INITIALIZED
);
return
-
1
;
}
return
ctx
->
pmeth
->
verify
(
ctx
,
sig
,
siglen
,
tbs
,
tbslen
);
}
int
EVP_PKEY_verify_recover_init
(
EVP_PKEY_CTX
*
ctx
,
EVP_PKEY
*
pkey
)
{
int
ret
;
if
(
!
ctx
||
!
ctx
->
pmeth
||
!
ctx
->
pmeth
->
verify_recover_init
)
{
EVPerr
(
EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT
,
EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE
);
return
-
2
;
}
ctx
->
operation
=
EVP_PKEY_OP_VERIFYRECOVER
;
ret
=
ctx
->
pmeth
->
verify_recover_init
(
ctx
,
pkey
);
if
(
ret
<=
0
)
ctx
->
operation
=
EVP_PKEY_OP_UNDEFINED
;
return
ret
;
}
int
EVP_PKEY_verify_recover
(
EVP_PKEY_CTX
*
ctx
,
unsigned
char
*
rout
,
int
*
routlen
,
unsigned
char
*
sig
,
int
siglen
)
{
if
(
!
ctx
||
!
ctx
->
pmeth
||
!
ctx
->
pmeth
->
verify_recover
)
{
EVPerr
(
EVP_F_EVP_PKEY_VERIFY_RECOVER
,
EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE
);
return
-
2
;
}
if
(
ctx
->
operation
!=
EVP_PKEY_OP_VERIFYRECOVER
)
{
EVPerr
(
EVP_F_EVP_PKEY_VERIFY_RECOVER
,
EVP_R_OPERATON_NOT_INITIALIZED
);
return
-
1
;
}
return
ctx
->
pmeth
->
verify_recover
(
ctx
,
rout
,
routlen
,
sig
,
siglen
);
}
int
EVP_PKEY_encrypt_init
(
EVP_PKEY_CTX
*
ctx
,
EVP_PKEY
*
pkey
)
{
int
ret
;
if
(
!
ctx
||
!
ctx
->
pmeth
||
!
ctx
->
pmeth
->
encrypt_init
)
{
EVPerr
(
EVP_F_EVP_PKEY_ENCRYPT_INIT
,
EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE
);
return
-
2
;
}
ctx
->
operation
=
EVP_PKEY_OP_ENCRYPT
;
ret
=
ctx
->
pmeth
->
encrypt_init
(
ctx
,
pkey
);
if
(
ret
<=
0
)
ctx
->
operation
=
EVP_PKEY_OP_UNDEFINED
;
return
ret
;
}
int
EVP_PKEY_encrypt
(
EVP_PKEY_CTX
*
ctx
,
unsigned
char
*
out
,
int
*
outlen
,
unsigned
char
*
in
,
int
inlen
)
{
if
(
!
ctx
||
!
ctx
->
pmeth
||
!
ctx
->
pmeth
->
encrypt
)
{
EVPerr
(
EVP_F_EVP_PKEY_ENCRYPT
,
EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE
);
return
-
2
;
}
if
(
ctx
->
operation
!=
EVP_PKEY_OP_ENCRYPT
)
{
EVPerr
(
EVP_F_EVP_PKEY_ENCRYPT
,
EVP_R_OPERATON_NOT_INITIALIZED
);
return
-
1
;
}
return
ctx
->
pmeth
->
encrypt
(
ctx
,
out
,
outlen
,
in
,
inlen
);
}
int
EVP_PKEY_decrypt_init
(
EVP_PKEY_CTX
*
ctx
,
EVP_PKEY
*
pkey
)
{
int
ret
;
if
(
!
ctx
||
!
ctx
->
pmeth
||
!
ctx
->
pmeth
->
decrypt_init
)
{
EVPerr
(
EVP_F_EVP_PKEY_DECRYPT_INIT
,
EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE
);
return
-
2
;
}
ctx
->
operation
=
EVP_PKEY_OP_DECRYPT
;
ret
=
ctx
->
pmeth
->
decrypt_init
(
ctx
,
pkey
);
if
(
ret
<=
0
)
ctx
->
operation
=
EVP_PKEY_OP_UNDEFINED
;
return
ret
;
}
int
EVP_PKEY_decrypt
(
EVP_PKEY_CTX
*
ctx
,
unsigned
char
*
out
,
int
*
outlen
,
unsigned
char
*
in
,
int
inlen
)
{
if
(
!
ctx
||
!
ctx
->
pmeth
||
!
ctx
->
pmeth
->
decrypt
)
{
EVPerr
(
EVP_F_EVP_PKEY_DECRYPT
,
EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE
);
return
-
2
;
}
if
(
ctx
->
operation
!=
EVP_PKEY_OP_DECRYPT
)
{
EVPerr
(
EVP_F_EVP_PKEY_DECRYPT
,
EVP_R_OPERATON_NOT_INITIALIZED
);
return
-
1
;
}
return
ctx
->
pmeth
->
decrypt
(
ctx
,
out
,
outlen
,
in
,
inlen
);
}
crypto/evp/pmeth_lib.c
浏览文件 @
f733a5ef
...
...
@@ -167,4 +167,12 @@ int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,
}
int
EVP_PKEY_CTX_ctrl_str
(
EVP_PKEY_CTX
*
ctx
,
char
*
name
,
char
*
value
)
{
if
(
!
ctx
||
!
ctx
->
pmeth
||
!
ctx
->
pmeth
->
ctrl
)
{
EVPerr
(
EVP_F_EVP_PKEY_CTX_CTRL
,
EVP_R_COMMAND_NOT_SUPPORTED
);
return
-
2
;
}
return
ctx
->
pmeth
->
ctrl_str
(
ctx
,
name
,
value
);
}
crypto/pkcs7/pk7_doit.c
浏览文件 @
f733a5ef
...
...
@@ -256,7 +256,7 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
{
ri
=
sk_PKCS7_RECIP_INFO_value
(
rsk
,
i
);
pkey
=
X509_get_pubkey
(
ri
->
cert
);
jj
=
EVP_PKEY_encrypt
(
tmp
,
key
,
keylen
,
pkey
);
jj
=
EVP_PKEY_encrypt
_old
(
tmp
,
key
,
keylen
,
pkey
);
EVP_PKEY_free
(
pkey
);
if
(
jj
<=
0
)
{
...
...
@@ -458,7 +458,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
for
(
i
=
0
;
i
<
sk_PKCS7_RECIP_INFO_num
(
rsk
);
i
++
)
{
ri
=
sk_PKCS7_RECIP_INFO_value
(
rsk
,
i
);
jj
=
EVP_PKEY_decrypt
(
tmp
,
jj
=
EVP_PKEY_decrypt
_old
(
tmp
,
M_ASN1_STRING_data
(
ri
->
enc_key
),
M_ASN1_STRING_length
(
ri
->
enc_key
),
pkey
);
...
...
@@ -476,7 +476,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
}
else
{
jj
=
EVP_PKEY_decrypt
(
tmp
,
jj
=
EVP_PKEY_decrypt
_old
(
tmp
,
M_ASN1_STRING_data
(
ri
->
enc_key
),
M_ASN1_STRING_length
(
ri
->
enc_key
),
pkey
);
if
(
jj
<=
0
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录