Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
c5f28105
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c5f28105
编写于
5月 19, 2015
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add functions to convert between uint64_t and ASN1_INTEGER.
Reviewed-by:
N
Rich Salz
<
rsalz@openssl.org
>
上级
de57d237
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
57 addition
and
0 deletion
+57
-0
crypto/asn1/a_int.c
crypto/asn1/a_int.c
+40
-0
crypto/asn1/asn1_err.c
crypto/asn1/asn1_err.c
+2
-0
doc/crypto/ASN1_INTEGER_get_int64.pod
doc/crypto/ASN1_INTEGER_get_int64.pod
+10
-0
include/openssl/asn1.h
include/openssl/asn1.h
+5
-0
未找到文件。
crypto/asn1/a_int.c
浏览文件 @
c5f28105
...
...
@@ -58,6 +58,7 @@
#include <stdio.h>
#include "internal/cryptlib.h"
#include "internal/numbers.h"
#include <limits.h>
#include <openssl/asn1.h>
#include <openssl/bn.h>
...
...
@@ -418,6 +419,35 @@ static int asn1_string_set_int64(ASN1_STRING *a, int64_t r, int itype)
return
ASN1_STRING_set
(
a
,
tbuf
,
l
);
}
static
int
asn1_string_get_uint64
(
uint64_t
*
pr
,
const
ASN1_STRING
*
a
,
int
itype
)
{
if
(
a
==
NULL
)
{
ASN1err
(
ASN1_F_ASN1_STRING_GET_UINT64
,
ERR_R_PASSED_NULL_PARAMETER
);
return
0
;
}
if
((
a
->
type
&
~
V_ASN1_NEG
)
!=
itype
)
{
ASN1err
(
ASN1_F_ASN1_STRING_GET_UINT64
,
ASN1_R_WRONG_INTEGER_TYPE
);
return
0
;
}
if
(
a
->
type
&
V_ASN1_NEG
)
{
ASN1err
(
ASN1_F_ASN1_STRING_GET_UINT64
,
ASN1_R_ILLEGAL_NEGATIVE_VALUE
);
return
0
;
}
return
asn1_get_uint64
(
pr
,
a
->
data
,
a
->
length
);
}
static
int
asn1_string_set_uint64
(
ASN1_STRING
*
a
,
uint64_t
r
,
int
itype
)
{
unsigned
char
tbuf
[
sizeof
(
r
)];
size_t
l
;
a
->
type
=
itype
;
l
=
asn1_put_uint64
(
tbuf
,
r
);
if
(
l
==
0
)
return
0
;
return
ASN1_STRING_set
(
a
,
tbuf
,
l
);
}
/*
* This is a version of d2i_ASN1_INTEGER that ignores the sign bit of ASN1
* integers: some broken software can encode a positive INTEGER with its MSB
...
...
@@ -560,6 +590,16 @@ int ASN1_INTEGER_set_int64(ASN1_INTEGER *a, int64_t r)
return
asn1_string_set_int64
(
a
,
r
,
V_ASN1_INTEGER
);
}
int
ASN1_INTEGER_get_uint64
(
uint64_t
*
pr
,
const
ASN1_INTEGER
*
a
)
{
return
asn1_string_get_uint64
(
pr
,
a
,
V_ASN1_INTEGER
);
}
int
ASN1_INTEGER_set_uint64
(
ASN1_INTEGER
*
a
,
uint64_t
r
)
{
return
asn1_string_set_uint64
(
a
,
r
,
V_ASN1_INTEGER
);
}
int
ASN1_INTEGER_set
(
ASN1_INTEGER
*
a
,
long
v
)
{
return
ASN1_INTEGER_set_int64
(
a
,
v
);
...
...
crypto/asn1/asn1_err.c
浏览文件 @
c5f28105
...
...
@@ -124,6 +124,7 @@ static ERR_STRING_DATA ASN1_str_functs[] = {
{
ERR_FUNC
(
ASN1_F_ASN1_SIGN
),
"ASN1_sign"
},
{
ERR_FUNC
(
ASN1_F_ASN1_STR2TYPE
),
"ASN1_STR2TYPE"
},
{
ERR_FUNC
(
ASN1_F_ASN1_STRING_GET_INT64
),
"ASN1_STRING_GET_INT64"
},
{
ERR_FUNC
(
ASN1_F_ASN1_STRING_GET_UINT64
),
"ASN1_STRING_GET_UINT64"
},
{
ERR_FUNC
(
ASN1_F_ASN1_STRING_SET
),
"ASN1_STRING_set"
},
{
ERR_FUNC
(
ASN1_F_ASN1_STRING_TABLE_ADD
),
"ASN1_STRING_TABLE_add"
},
{
ERR_FUNC
(
ASN1_F_ASN1_STRING_TO_BN
),
"ASN1_STRING_TO_BN"
},
...
...
@@ -251,6 +252,7 @@ static ERR_STRING_DATA ASN1_str_reasons[] = {
{
ERR_REASON
(
ASN1_R_ILLEGAL_HEX
),
"illegal hex"
},
{
ERR_REASON
(
ASN1_R_ILLEGAL_IMPLICIT_TAG
),
"illegal implicit tag"
},
{
ERR_REASON
(
ASN1_R_ILLEGAL_INTEGER
),
"illegal integer"
},
{
ERR_REASON
(
ASN1_R_ILLEGAL_NEGATIVE_VALUE
),
"illegal negative value"
},
{
ERR_REASON
(
ASN1_R_ILLEGAL_NESTED_TAGGING
),
"illegal nested tagging"
},
{
ERR_REASON
(
ASN1_R_ILLEGAL_NULL
),
"illegal null"
},
{
ERR_REASON
(
ASN1_R_ILLEGAL_NULL_VALUE
),
"illegal null value"
},
...
...
doc/crypto/ASN1_INTEGER_get_int64.pod
浏览文件 @
c5f28105
...
...
@@ -14,6 +14,9 @@ ASN1_INTEGER_get_int64, ASN1_INTEGER_get, ASN1_INTEGER_set_int64, ASN1_INTEGER_s
int ASN1_INTEGER_set_int64(ASN1_INTEGER *a, int64_t r);
long ASN1_INTEGER_set(const ASN1_INTEGER *a);
int ASN1_INTEGER_get_uint64(uint64_t *pr, const ASN1_INTEGER *a);
int ASN1_INTEGER_set_uint64(ASN1_INTEGER *a, uint64_t r);
ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);
BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn);
...
...
@@ -36,6 +39,10 @@ If successful it returns 1 and sets B<*pr> to the value of B<a>. If it fails
(due to invalid type or the value being too big to fit into an B<int64_t> type)
it returns 0.
ASN1_INTEGER_get_uint64() is similar to ASN1_INTEGER_get_int64_t() except it
converts to a B<uint64_t> type and an error is returned if the passed integer
is negative.
ASN1_INTEGER_get() also returns the value of B<a> but it returns 0 if B<a> is
NULL and -1 on error (which is ambiguous because -1 is a legitimate value for
an B<ASN1_INTEGER>). New applications should use ASN1_INTEGER_get_int64()
...
...
@@ -44,6 +51,9 @@ instead.
ASN1_INTEGER_set_int64() sets the value of B<ASN1_INTEGER> B<a> to the
B<int64_t> value B<r>.
ASN1_INTEGER_set_uint64() sets the value of B<ASN1_INTEGER> B<a> to the
B<uint64_t> value B<r>.
ASN1_INTEGER_set() sets the value of B<ASN1_INTEGER> B<a> to the B<long> value
B<v>.
...
...
include/openssl/asn1.h
浏览文件 @
c5f28105
...
...
@@ -679,6 +679,9 @@ ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,
int
ASN1_INTEGER_get_int64
(
int64_t
*
pr
,
const
ASN1_INTEGER
*
a
);
int
ASN1_INTEGER_set_int64
(
ASN1_INTEGER
*
a
,
int64_t
r
);
int
ASN1_INTEGER_get_uint64
(
uint64_t
*
pr
,
const
ASN1_INTEGER
*
a
);
int
ASN1_INTEGER_set_uint64
(
ASN1_INTEGER
*
a
,
uint64_t
r
);
int
ASN1_INTEGER_set
(
ASN1_INTEGER
*
a
,
long
v
);
long
ASN1_INTEGER_get
(
const
ASN1_INTEGER
*
a
);
ASN1_INTEGER
*
BN_to_ASN1_INTEGER
(
const
BIGNUM
*
bn
,
ASN1_INTEGER
*
ai
);
...
...
@@ -967,6 +970,7 @@ void ERR_load_ASN1_strings(void);
# define ASN1_F_ASN1_SIGN 128
# define ASN1_F_ASN1_STR2TYPE 179
# define ASN1_F_ASN1_STRING_GET_INT64 227
# define ASN1_F_ASN1_STRING_GET_UINT64 230
# define ASN1_F_ASN1_STRING_SET 186
# define ASN1_F_ASN1_STRING_TABLE_ADD 129
# define ASN1_F_ASN1_STRING_TO_BN 228
...
...
@@ -1085,6 +1089,7 @@ void ERR_load_ASN1_strings(void);
# define ASN1_R_ILLEGAL_HEX 178
# define ASN1_R_ILLEGAL_IMPLICIT_TAG 179
# define ASN1_R_ILLEGAL_INTEGER 180
# define ASN1_R_ILLEGAL_NEGATIVE_VALUE 226
# define ASN1_R_ILLEGAL_NESTED_TAGGING 181
# define ASN1_R_ILLEGAL_NULL 125
# define ASN1_R_ILLEGAL_NULL_VALUE 182
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录