Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
openssl
提交
4882171d
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,发现更多精彩内容 >>
提交
4882171d
编写于
3月 08, 2002
作者:
B
Bodo Möller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
EC curve stuff
Submitted by: Nils Larsch
上级
931627e6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
87 addition
and
41 deletion
+87
-41
apps/ecdsaparam.c
apps/ecdsaparam.c
+75
-37
crypto/asn1/t_pkey.c
crypto/asn1/t_pkey.c
+11
-3
crypto/ec/ec_curve.c
crypto/ec/ec_curve.c
+1
-1
未找到文件。
apps/ecdsaparam.c
浏览文件 @
4882171d
...
...
@@ -149,6 +149,21 @@
* -X9_62_239v2 - use the X9_62 239v2 example curve over a 239 bit prime field
* -X9_62_239v3 - use the X9_62 239v3 example curve over a 239 bit prime field
* -X9_62_256v1 - use the X9_62 239v1 example curve over a 256 bit prime field
* -SECG_PRIME_112R1 - use the SECG 112r1 recommeded curve over a 112 bit prime field
* -SECG_PRIME_112R2 - use the SECG 112r2 recommeded curve over a 112 bit prime field
* -SECG_PRIME_128R1 - use the SECG 128r1 recommeded curve over a 128 bit prime field
* -SECG_PRIME_128R2 - use the SECG 128r2 recommeded curve over a 128 bit prime field
* -SECG_PRIME_160K1 - use the SECG 160k1 recommeded curve over a 160 bit prime field
* -SECG_PRIME_160R1 - use the SECG 160r1 recommeded curve over a 160 bit prime field
* -SECG_PRIME_160R2 - use the SECG 160r2 recommeded curve over a 160 bit prime field
* -SECG_PRIME_192K1 - use the SECG 192k1 recommeded curve over a 192 bit prime field
* -SECG_PRIME_192R1 - use the SECG 192r1 recommeded curve over a 192 bit prime field
* -SECG_PRIME_224K1 - use the SECG 224k1 recommeded curve over a 224 bit prime field
* -SECG_PRIME_224R1 - use the SECG 224r1 recommeded curve over a 224 bit prime field
* -SECG_PRIME_256K1 - use the SECG 256k1 recommeded curve over a 256 bit prime field
* -SECG_PRIME_256R1 - use the SECG 256r1 recommeded curve over a 256 bit prime field
* -SECG_PRIME_384R1 - use the SECG 384r1 recommeded curve over a 384 bit prime field
* -SECG_PRIME_521R1 - use the SECG 521r1 recommeded curve over a 521 bit prime field
*/
int
MAIN
(
int
,
char
**
);
...
...
@@ -304,28 +319,43 @@ int MAIN(int argc, char **argv)
bad:
BIO_printf
(
bio_err
,
"%s [options] [bits] <infile >outfile
\n
"
,
prog
);
BIO_printf
(
bio_err
,
"where options are
\n
"
);
BIO_printf
(
bio_err
,
" -inform arg input format - DER or PEM
\n
"
);
BIO_printf
(
bio_err
,
" -outform arg output format - DER or PEM
\n
"
);
BIO_printf
(
bio_err
,
" -in arg input file
\n
"
);
BIO_printf
(
bio_err
,
" -out arg output file
\n
"
);
BIO_printf
(
bio_err
,
" -text print the key in text
\n
"
);
BIO_printf
(
bio_err
,
" -C Output C code
\n
"
);
BIO_printf
(
bio_err
,
" -noout no output
\n
"
);
BIO_printf
(
bio_err
,
" -rand files to use for random number input
\n
"
);
BIO_printf
(
bio_err
,
" -engine e use engine e, possibly a hardware device.
\n
"
);
BIO_printf
(
bio_err
,
" -named_curve use the curve oid instead of the parameters
\n
"
);
BIO_printf
(
bio_err
,
" -NIST_192 use the NIST recommeded curve parameters over a 192 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -NIST_224 use the NIST recommeded curve parameters over a 224 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -NIST_256 use the NIST recommeded curve parameters over a 256 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -NIST_384 use the NIST recommeded curve parameters over a 384 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -NIST_521 use the NIST recommeded curve parameters over a 521 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -X9_62_192v1 use the X9_62 192v1 example curve over a 192 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -X9_62_192v2 use the X9_62 192v2 example curve over a 192 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -X9_62_192v3 use the X9_62 192v3 example curve over a 192 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -X9_62_239v1 use the X9_62 239v1 example curve over a 239 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -X9_62_239v2 use the X9_62 239v2 example curve over a 239 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -X9_62_239v3 use the X9_62 239v3 example curve over a 239 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -X9_62_256v1 use the X9_62 239v1 example curve over a 256 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -inform arg input format - DER or PEM
\n
"
);
BIO_printf
(
bio_err
,
" -outform arg output format - DER or PEM
\n
"
);
BIO_printf
(
bio_err
,
" -in arg input file
\n
"
);
BIO_printf
(
bio_err
,
" -out arg output file
\n
"
);
BIO_printf
(
bio_err
,
" -text print the key in text
\n
"
);
BIO_printf
(
bio_err
,
" -C Output C code
\n
"
);
BIO_printf
(
bio_err
,
" -noout no output
\n
"
);
BIO_printf
(
bio_err
,
" -rand files to use for random number input
\n
"
);
BIO_printf
(
bio_err
,
" -engine e use engine e, possibly a hardware device.
\n
"
);
BIO_printf
(
bio_err
,
" -named_curve use the curve oid instead of the parameters
\n
"
);
BIO_printf
(
bio_err
,
" -NIST_192 use the NIST recommeded curve parameters over a 192 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -NIST_224 use the NIST recommeded curve parameters over a 224 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -NIST_256 use the NIST recommeded curve parameters over a 256 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -NIST_384 use the NIST recommeded curve parameters over a 384 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -NIST_521 use the NIST recommeded curve parameters over a 521 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -X9_62_192v1 use the X9_62 192v1 example curve over a 192 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -X9_62_192v2 use the X9_62 192v2 example curve over a 192 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -X9_62_192v3 use the X9_62 192v3 example curve over a 192 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -X9_62_239v1 use the X9_62 239v1 example curve over a 239 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -X9_62_239v2 use the X9_62 239v2 example curve over a 239 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -X9_62_239v3 use the X9_62 239v3 example curve over a 239 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -X9_62_256v1 use the X9_62 239v1 example curve over a 256 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -SECG_PRIME_112R1 use the SECG 112r1 recommeded curve over a 112 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -SECG_PRIME_112R2 use the SECG 112r2 recommeded curve over a 112 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -SECG_PRIME_128R1 use the SECG 128r1 recommeded curve over a 128 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -SECG_PRIME_128R2 use the SECG 128r2 recommeded curve over a 128 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -SECG_PRIME_160K1 use the SECG 160k1 recommeded curve over a 160 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -SECG_PRIME_160R1 use the SECG 160r1 recommeded curve over a 160 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -SECG_PRIME_160R2 use the SECG 160r2 recommeded curve over a 160 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -SECG_PRIME_192K1 use the SECG 192k1 recommeded curve over a 192 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -SECG_PRIME_192R1 use the SECG 192r1 recommeded curve over a 192 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -SECG_PRIME_224K1 use the SECG 224k1 recommeded curve over a 224 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -SECG_PRIME_224R1 use the SECG 224r1 recommeded curve over a 224 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -SECG_PRIME_256K1 use the SECG 256k1 recommeded curve over a 256 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -SECG_PRIME_256R1 use the SECG 256r1 recommeded curve over a 256 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -SECG_PRIME_384R1 use the SECG 384r1 recommeded curve over a 384 bit prime field
\n
"
);
BIO_printf
(
bio_err
,
" -SECG_PRIME_521R1 use the SECG 521r1 recommeded curve over a 521 bit prime field
\n
"
);
goto
end
;
}
...
...
@@ -505,29 +535,37 @@ bad:
*/
printf
(
"ECDSA *get_ecdsa%d(void)
\n\t
{
\n
"
,
bits_p
);
printf
(
"
\t
int ok=0;
\n
"
);
printf
(
"
\t
ECDSA *ecdsa=NULL;
\n
"
);
printf
(
"
\t
EC_POINT *point=NULL;
\n
"
);
printf
(
"
\t
BIGNUM *tmp_1=NULL,*tmp_2=NULL,*tmp_3=NULL;
\n\n
"
);
printf
(
"
\t
if ((ecdsa=ECDSA_new()) == NULL)
\n
"
);
printf
(
"
\t\t
return(NULL);
\n\n
"
);
printf
(
"
\t
/* generate EC_GROUP structure */
\n
"
);
printf
(
"
\t
tmp_1 = BN_bin2bn(ecdsa%d_p, sizeof(ecdsa%d_p), NULL)
;
\n
"
,
bits_p
,
bits_p
);
printf
(
"
\t
tmp_2 = BN_bin2bn(ecdsa%d_a, sizeof(ecdsa%d_a), NULL)
;
\n
"
,
bits_p
,
bits_p
);
printf
(
"
\t
tmp_3 = BN_bin2bn(ecdsa%d_b, sizeof(ecdsa%d_b), NULL)
;
\n
"
,
bits_p
,
bits_p
);
printf
(
"
\t
ecdsa->group = EC_GROUP_new_curve_GFp(tmp_1, tmp_2, tmp_3, NULL)
;
\n\n
"
);
printf
(
"
\t
if ((tmp_1 = BN_bin2bn(ecdsa%d_p, sizeof(ecdsa%d_p), NULL)) == NULL) goto err
;
\n
"
,
bits_p
,
bits_p
);
printf
(
"
\t
if ((tmp_2 = BN_bin2bn(ecdsa%d_a, sizeof(ecdsa%d_a), NULL)) == NULL) goto err
;
\n
"
,
bits_p
,
bits_p
);
printf
(
"
\t
if ((tmp_3 = BN_bin2bn(ecdsa%d_b, sizeof(ecdsa%d_b), NULL)) == NULL) goto err
;
\n
"
,
bits_p
,
bits_p
);
printf
(
"
\t
if ((ecdsa->group = EC_GROUP_new_curve_GFp(tmp_1, tmp_2, tmp_3, NULL)) == NULL) goto err
;
\n\n
"
);
printf
(
"
\t
/* build generator */
\n
"
);
printf
(
"
\t
BN_bin2bn(ecdsa%d_x, sizeof(ecdsa%d_x), tmp_1);
\n
"
,
bits_p
,
bits_p
);
printf
(
"
\t
BN_bin2bn(ecdsa%d_y, sizeof(ecdsa%d_y), tmp_2);
\n
"
,
bits_p
,
bits_p
);
printf
(
"
\t
if ((point = EC_POINT_new(ecdsa->group)) == NULL)
\n
"
);
printf
(
"
\t\t
{
\n\t\t
ECDSA_free(ecdsa); BN_free(tmp_1); BN_free(tmp_2); BN_free(tmp_3);
\n
"
);
printf
(
"
\t\t
return(NULL);
\n\t\t
}
\n
"
);
printf
(
"
\t
EC_POINT_set_affine_coordinates_GFp(ecdsa->group, point, tmp_1, tmp_2, NULL);
\n
"
);
printf
(
"
\t
if (!BN_bin2bn(ecdsa%d_x, sizeof(ecdsa%d_x), tmp_1)) goto err;
\n
"
,
bits_p
,
bits_p
);
printf
(
"
\t
if (!BN_bin2bn(ecdsa%d_y, sizeof(ecdsa%d_y), tmp_2)) goto err;
\n
"
,
bits_p
,
bits_p
);
printf
(
"
\t
if ((point = EC_POINT_new(ecdsa->group)) == NULL) goto err;
\n
"
);
printf
(
"
\t
if (!EC_POINT_set_affine_coordinates_GFp(ecdsa->group, point, tmp_1, tmp_2, NULL)) goto err;
\n
"
);
printf
(
"
\t
/* set generator, order and cofactor */
\n
"
);
printf
(
"
\t
BN_bin2bn(ecdsa%d_o, sizeof(ecdsa%d_o), tmp_1);
\n
"
,
bits_p
,
bits_p
);
printf
(
"
\t
BN_bin2bn(ecdsa%d_c, sizeof(ecdsa%d_c), tmp_2);
\n
"
,
bits_p
,
bits_p
);
printf
(
"
\t
EC_GROUP_set_generator(ecdsa->group, point, tmp_1, tmp_2);
\n
"
);
printf
(
"
\t
BN_free(tmp_1); BN_free(tmp_2); BN_free(tmp_3);
\n
"
);
printf
(
"
\t
EC_POINT_free(point);
\n\n
"
);
printf
(
"
\t
if (!BN_bin2bn(ecdsa%d_o, sizeof(ecdsa%d_o), tmp_1)) goto err;
\n
"
,
bits_p
,
bits_p
);
printf
(
"
\t
if (!BN_bin2bn(ecdsa%d_c, sizeof(ecdsa%d_c), tmp_2)) goto err;
\n
"
,
bits_p
,
bits_p
);
printf
(
"
\t
if (!EC_GROUP_set_generator(ecdsa->group, point, tmp_1, tmp_2)) goto err;
\n
"
);
printf
(
"
\n\t
ok=1;
\n
"
);
printf
(
"err:
\n
"
);
printf
(
"
\t
if (tmp_1) BN_free(tmp_1);
\n
"
);
printf
(
"
\t
if (tmp_2) BN_free(tmp_2);
\n
"
);
printf
(
"
\t
if (tmp_3) BN_free(tmp_3);
\n
"
);
printf
(
"
\t
if (point) EC_POINT_free(point);
\n
"
);
printf
(
"
\t
if (!ok)
\n
"
);
printf
(
"
\t\t
{
\n
"
);
printf
(
"
\t\t
ECDSA_free(ecdsa);
\n
"
);
printf
(
"
\t\t
ecdsa = NULL;
\n
"
);
printf
(
"
\t\t
}
\n
"
);
printf
(
"
\t
return(ecdsa);
\n\t
}
\n
"
);
}
...
...
crypto/asn1/t_pkey.c
浏览文件 @
4882171d
...
...
@@ -519,7 +519,8 @@ int ECDSAParameters_print(BIO *bp, const ECDSA *x)
unsigned
char
*
buffer
=
NULL
;
int
buf_len
;
int
reason
=
ERR_R_EC_LIB
,
i
,
ret
=
0
;
BIGNUM
*
tmp_1
=
NULL
,
*
tmp_2
=
NULL
,
*
tmp_3
=
NULL
,
*
tmp_4
=
NULL
;
BIGNUM
*
tmp_1
=
NULL
,
*
tmp_2
=
NULL
,
*
tmp_3
=
NULL
,
*
tmp_4
=
NULL
,
*
tmp_5
=
NULL
,
*
tmp_6
=
NULL
;
BN_CTX
*
ctx
=
NULL
;
EC_POINT
*
point
=
NULL
;
...
...
@@ -530,13 +531,16 @@ int ECDSAParameters_print(BIO *bp, const ECDSA *x)
goto
err
;
}
if
((
tmp_1
=
BN_new
())
==
NULL
||
(
tmp_2
=
BN_new
())
==
NULL
||
(
tmp_3
=
BN_new
())
==
NULL
||
(
ctx
=
BN_CTX_new
())
==
NULL
)
(
tmp_3
=
BN_new
())
==
NULL
||
(
tmp_5
=
BN_new
())
==
NULL
||
(
tmp_6
=
BN_new
())
==
NULL
||
(
ctx
=
BN_CTX_new
())
==
NULL
)
{
reason
=
ERR_R_MALLOC_FAILURE
;
goto
err
;
}
if
(
!
EC_GROUP_get_curve_GFp
(
x
->
group
,
tmp_1
,
tmp_2
,
tmp_3
,
ctx
))
goto
err
;
if
((
point
=
EC_GROUP_get0_generator
(
x
->
group
))
==
NULL
)
goto
err
;
if
(
!
EC_GROUP_get_order
(
x
->
group
,
tmp_5
,
ctx
))
goto
err
;
if
(
!
EC_GROUP_get_cofactor
(
x
->
group
,
tmp_6
,
ctx
))
goto
err
;
buf_len
=
EC_POINT_point2oct
(
x
->
group
,
point
,
POINT_CONVERSION_COMPRESSED
,
NULL
,
0
,
ctx
);
if
(
!
buf_len
||
(
buffer
=
OPENSSL_malloc
(
buf_len
))
==
NULL
)
{
...
...
@@ -565,13 +569,17 @@ int ECDSAParameters_print(BIO *bp, const ECDSA *x)
if
(
!
print
(
bp
,
"Prime p:"
,
tmp_1
,
buffer
,
4
))
goto
err
;
if
(
!
print
(
bp
,
"Curve a:"
,
tmp_2
,
buffer
,
4
))
goto
err
;
if
(
!
print
(
bp
,
"Curve b:"
,
tmp_3
,
buffer
,
4
))
goto
err
;
if
(
!
print
(
bp
,
"Generator ( compressed ) :"
,
tmp_4
,
buffer
,
4
))
goto
err
;
if
(
!
print
(
bp
,
"Generator (compressed):"
,
tmp_4
,
buffer
,
4
))
goto
err
;
if
(
!
print
(
bp
,
"Order:"
,
tmp_5
,
buffer
,
4
))
goto
err
;
if
(
!
print
(
bp
,
"Cofactor:"
,
tmp_6
,
buffer
,
4
))
goto
err
;
ret
=
1
;
err:
if
(
tmp_1
)
BN_free
(
tmp_1
);
if
(
tmp_2
)
BN_free
(
tmp_2
);
if
(
tmp_3
)
BN_free
(
tmp_3
);
if
(
tmp_4
)
BN_free
(
tmp_4
);
if
(
tmp_5
)
BN_free
(
tmp_5
);
if
(
tmp_6
)
BN_free
(
tmp_6
);
if
(
ctx
)
BN_CTX_free
(
ctx
);
if
(
buffer
)
OPENSSL_free
(
buffer
);
ECDSAerr
(
ECDSA_F_ECDSAPARAMETERS_PRINT
,
reason
);
...
...
crypto/ec/ec_curve.c
浏览文件 @
4882171d
...
...
@@ -153,7 +153,7 @@
"D6031998D1B3BBFEBF59CC9BBFF9AEE1",\
"5EEEFCA380D02919DC2C6558BB6D8A5D",\
"7B6AA5D85E572983E6FB32A7CDEBC140",0,\
"3FFFFFFF
7FFFFFFF BE002472
0613B5A3",4
"3FFFFFFF
7FFFFFFFBE002472
0613B5A3",4
#define _EC_GROUP_SECG_PRIME_160K1 \
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73",\
"0",\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录