Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
43636910
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
1 年多 前同步成功
通知
9
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看板
提交
43636910
编写于
7月 08, 2006
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add some examples.
上级
6535bd42
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
156 addition
and
6 deletion
+156
-6
doc/crypto/EVP_PKEY_decrypt.pod
doc/crypto/EVP_PKEY_decrypt.pod
+31
-1
doc/crypto/EVP_PKEY_encrypt.pod
doc/crypto/EVP_PKEY_encrypt.pod
+31
-1
doc/crypto/EVP_PKEY_sign.pod
doc/crypto/EVP_PKEY_sign.pod
+35
-2
doc/crypto/EVP_PKEY_verify.pod
doc/crypto/EVP_PKEY_verify.pod
+26
-1
doc/crypto/EVP_PKEY_verifyrecover.pod
doc/crypto/EVP_PKEY_verifyrecover.pod
+33
-1
未找到文件。
doc/crypto/EVP_PKEY_decrypt.pod
浏览文件 @
43636910
...
...
@@ -45,7 +45,37 @@ indicates the operation is not supported by the public key algorithm.
Decrypt data using OAEP (for RSA keys):
[to be added]
#include <openssl/evp.h>
#include <openssl/rsa.h>
EVP_PKEY_CTX *ctx;
unsigned char *out, *in;
size_t outlen, inlen;
EVP_PKEY *key;
/* NB: assumes key in, inlen are already set up
* and that key is an RSA private key
*/
ctx = EVP_PKEY_CTX_new(key);
if (!ctx)
/* Error occurred */
if (EVP_PKEY_decrypt_init(ctx) <= 0)
/* Error */
if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_OAEP_PADDING) <= 0)
/* Error */
/* Determine buffer length */
if (EVP_PKEY_decrypt(ctx, NULL, &outlen, in, inlen) <= 0)
/* Error */
out = OPENSSL_malloc(outlen);
if (!out)
/* malloc failure */
if (EVP_PKEY_decrypt(ctx, out, &outlen, in, inlen) <= 0)
/* Error */
/* Decrypted data is outlen bytes written to buffer out */
=head1 SEE ALSO
...
...
doc/crypto/EVP_PKEY_encrypt.pod
浏览文件 @
43636910
...
...
@@ -45,7 +45,37 @@ indicates the operation is not supported by the public key algorithm.
Encrypt data using OAEP (for RSA keys):
[to be added]
#include <openssl/evp.h>
#include <openssl/rsa.h>
EVP_PKEY_CTX *ctx;
unsigned char *out, *in;
size_t outlen, inlen;
EVP_PKEY *key;
/* NB: assumes key in, inlen are already set up
* and that key is an RSA public key
*/
ctx = EVP_PKEY_CTX_new(key);
if (!ctx)
/* Error occurred */
if (EVP_PKEY_encrypt_init(ctx) <= 0)
/* Error */
if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_OAEP_PADDING) <= 0)
/* Error */
/* Determine buffer length */
if (EVP_PKEY_encrypt(ctx, NULL, &outlen, in, inlen) <= 0)
/* Error */
out = OPENSSL_malloc(outlen);
if (!out)
/* malloc failure */
if (EVP_PKEY_encrypt(ctx, out, &outlen, in, inlen) <= 0)
/* Error */
/* Encrypted data is outlen bytes written to buffer out */
=head1 SEE ALSO
...
...
doc/crypto/EVP_PKEY_sign.pod
浏览文件 @
43636910
...
...
@@ -43,9 +43,42 @@ indicates the operation is not supported by the public key algorithm.
=head1 EXAMPLE
Sign data using PKCS#1 and SHA256 digest:
Sign data using RSA with PKCS#1 padding and SHA256 digest:
#include <openssl/evp.h>
#include <openssl/rsa.h>
EVP_PKEY_CTX *ctx;
unsigned char *md, *sig;
size_t mdlen, siglen;
EVP_PKEY *signing_key;
/* NB: assumes signing_key, md and mdlen are already set up
* and that signing_key is an RSA private key
*/
ctx = EVP_PKEY_CTX_new(signing_key);
if (!ctx)
/* Error occurred */
if (EVP_PKEY_sign_init(ctx) <= 0)
/* Error */
if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)
/* Error */
if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0)
/* Error */
/* Determine buffer length */
if (EVP_PKEY_sign(ctx, NULL, &siglen, md, mdlen) <= 0)
/* Error */
sig = OPENSSL_malloc(siglen);
if (!sig)
/* malloc failure */
if (EVP_PKEY_sign(ctx, sig, &siglen, md, mdlen) <= 0)
/* Error */
/* Signature is siglen bytes written to buffer sig */
[to be added]
=head1 SEE ALSO
...
...
doc/crypto/EVP_PKEY_verify.pod
浏览文件 @
43636910
...
...
@@ -48,7 +48,32 @@ the public key algorithm.
Verify signature using PKCS#1 and SHA256 digest:
[to be added]
#include <openssl/evp.h>
#include <openssl/rsa.h>
EVP_PKEY_CTX *ctx;
unsigned char *md, *sig;
size_t mdlen, siglen;
EVP_PKEY *verify_key;
/* NB: assumes verify_key, sig, siglen md and mdlen are already set up
* and that verify_key is an RSA public key
*/
ctx = EVP_PKEY_CTX_new(verify_key);
if (!ctx)
/* Error occurred */
if (EVP_PKEY_verify_init(ctx) <= 0)
/* Error */
if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)
/* Error */
if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0)
/* Error */
/* Perform operation */
ret = EVP_PKEY_verify(ctx, md, mdlen, sig, siglen);
/* ret == 1 indicates success, 0 verify failure and < 0 for some
* other error.
*/
=head1 SEE ALSO
...
...
doc/crypto/EVP_PKEY_verifyrecover.pod
浏览文件 @
43636910
...
...
@@ -53,7 +53,39 @@ indicates the operation is not supported by the public key algorithm.
Recover digest originally signed using PKCS#1 and SHA256 digest:
[to be added]
#include <openssl/evp.h>
#include <openssl/rsa.h>
EVP_PKEY_CTX *ctx;
unsigned char *rout, *sig;
size_t routlen, siglen;
EVP_PKEY *verify_key;
/* NB: assumes verify_key, sig and siglen are already set up
* and that verify_key is an RSA public key
*/
ctx = EVP_PKEY_CTX_new(verify_key);
if (!ctx)
/* Error occurred */
if (EVP_PKEY_verifyrecover_init(ctx) <= 0)
/* Error */
if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)
/* Error */
if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0)
/* Error */
/* Determine buffer length */
if (EVP_PKEY_verifyrecover(ctx, rout, &routlen, sig, siglen) <= 0)
/* Error */
rout = OPENSSL_malloc(routlen);
if (!rout)
/* malloc failure */
if (EVP_PKEY_verifyrecover(ctx, rout, &routlen, sig, siglen) <= 0)
/* Error */
/* Recovered data is routlen bytes written to buffer rout */
=head1 SEE ALSO
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录