Fix small mistake on x509 structure. (#5690)
* Fix small mistake on x509 structure. * Add test with ed25519 certificate
This commit is contained in:
parent
edfe7d3380
commit
5ef76f42b8
2 changed files with 116 additions and 24 deletions
|
|
@ -604,7 +604,7 @@ static void x509_subjectpublickeyinfo_to_structure(RzStructuredData *parent, RzX
|
|||
}
|
||||
rz_asn1_string_free(m);
|
||||
} else if (spki->subjectPublicKey) {
|
||||
m = rz_asn1_stringify_bytes(spki->subjectPublicKeyExponent->binary, spki->subjectPublicKeyExponent->length);
|
||||
m = rz_asn1_stringify_bytes(spki->subjectPublicKey->binary, spki->subjectPublicKey->length);
|
||||
if (m) {
|
||||
rz_structured_data_map_add_string(parent, "subjectPublicKey", m->string);
|
||||
}
|
||||
|
|
@ -617,7 +617,6 @@ static void x509_extensions_to_structure(RzStructuredData *parent, RzX509Extensi
|
|||
return;
|
||||
}
|
||||
|
||||
RzASN1String *m = NULL;
|
||||
RzStructuredData *extensions = rz_structured_data_map_add_array(parent, "extensions");
|
||||
for (ut32 i = 0; i < exts->length; i++) {
|
||||
RzX509Extension *e = exts->extensions[i];
|
||||
|
|
@ -632,29 +631,34 @@ static void x509_extensions_to_structure(RzStructuredData *parent, RzX509Extensi
|
|||
if (e->critical) {
|
||||
rz_structured_data_map_add_boolean(extension, "critical", e->critical);
|
||||
}
|
||||
if (e->extnValue) {
|
||||
if (rz_str_is_printable_limited((const char *)e->extnValue->binary, e->extnValue->length)) {
|
||||
m = rz_asn1_stringify_string(e->extnValue->binary, e->extnValue->length);
|
||||
} else if (e->extnValue->length > 3) {
|
||||
RzASN1Object *obj = rz_asn1_object_parse(e->extnValue->binary, e->extnValue->length);
|
||||
if (obj) {
|
||||
RzStructuredData *sd = rz_asn1_to_structure(obj, true);
|
||||
rz_asn1_object_free(obj);
|
||||
rz_structured_data_map_add(extension, "extnValue", sd);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!m && e->extnValue->length < 20) {
|
||||
m = rz_asn1_stringify_integer(e->extnValue->binary, e->extnValue->length);
|
||||
} else if (!m) {
|
||||
m = rz_asn1_stringify_bytes(e->extnValue->binary, e->extnValue->length);
|
||||
}
|
||||
if (m) {
|
||||
rz_structured_data_map_add_string(extension, "extnValue", m->string);
|
||||
}
|
||||
rz_asn1_string_free(m);
|
||||
if (!e->extnValue) {
|
||||
continue;
|
||||
}
|
||||
|
||||
RzASN1String *m = NULL;
|
||||
const RzASN1Binary *val = e->extnValue;
|
||||
|
||||
if (rz_str_is_printable_limited((const char *)val->binary, val->length)) {
|
||||
m = rz_asn1_stringify_string(val->binary, val->length);
|
||||
} else if (val->length > 3) {
|
||||
RzASN1Object *obj = rz_asn1_object_parse(val->binary, val->length);
|
||||
if (obj) {
|
||||
RzStructuredData *sd = rz_asn1_to_structure(obj, true);
|
||||
rz_asn1_object_free(obj);
|
||||
rz_structured_data_map_add(extension, "extnValue", sd);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!m && val->length < 20) {
|
||||
m = rz_asn1_stringify_integer(val->binary, val->length);
|
||||
} else if (!m) {
|
||||
m = rz_asn1_stringify_bytes(val->binary, val->length);
|
||||
}
|
||||
if (m) {
|
||||
rz_structured_data_map_add_string(extension, "extnValue", m->string);
|
||||
}
|
||||
rz_asn1_string_free(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1383,3 +1383,91 @@ pe32:
|
|||
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=x509 ed25519
|
||||
FILE==
|
||||
CMDS=<<EOF
|
||||
b 0x200
|
||||
w6d MIIBCDCBuwIUGW78zw0OL0GptJi++a91dBa7DsQwBQYDK2VwMCcxCzAJBgNVBAYTAkRFMRgwFgYDVQQDDA93d3cuZXhhbXBsZS5jb20wHhcNMTkwMzMxMTc1MTIyWhcNMjEwMjI4MTc1MTIyWjAnMQswCQYDVQQGEwJERTEYMBYGA1UEAwwPd3d3LmV4YW1wbGUuY29tMCowBQYDK2VwAyEAK87g0b8CC1eA5mvKXt9uezZwJYWEyg74Y0xTZEkqCcwwBQYDK2VwA0EAIIu/aa3Qtr3IE5to/nvWVY9y3ciwG5DnA70X3ALUhFs+U5aLtfY8sNT1Ng72ht+UBwByuze20UsL9qMsmknQCA==
|
||||
pFa
|
||||
echo ---
|
||||
pFx
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
0 264: 0: cons SEQUENCE :
|
||||
4 187: 1: cons SEQUENCE :
|
||||
7 20: 2: prim INTEGER : 19 6e fc cf 0d 0e 2f 41 a9 b4 98 be f9 af 75 74 |.n..../A......ut|
|
||||
: 16 bb 0e c4 |.... |
|
||||
29 5: 2: cons SEQUENCE :
|
||||
31 3: 3: prim OBJECT_IDENTIFIER : ed25519 (1.3.101.112)
|
||||
36 39: 2: cons SEQUENCE :
|
||||
38 11: 3: cons SET :
|
||||
40 9: 4: cons SEQUENCE :
|
||||
42 3: 5: prim OBJECT_IDENTIFIER : countryName (2.5.4.6)
|
||||
47 2: 5: prim PrintableString : DE
|
||||
51 24: 3: cons SET :
|
||||
53 22: 4: cons SEQUENCE :
|
||||
55 3: 5: prim OBJECT_IDENTIFIER : commonName (2.5.4.3)
|
||||
60 15: 5: prim UTF8String : www.example.com
|
||||
77 30: 2: cons SEQUENCE :
|
||||
79 13: 3: prim UTCTime : 31/03/2019 17:51:22 GMT
|
||||
94 13: 3: prim UTCTime : 28/02/2021 17:51:22 GMT
|
||||
109 39: 2: cons SEQUENCE :
|
||||
111 11: 3: cons SET :
|
||||
113 9: 4: cons SEQUENCE :
|
||||
115 3: 5: prim OBJECT_IDENTIFIER : countryName (2.5.4.6)
|
||||
120 2: 5: prim PrintableString : DE
|
||||
124 24: 3: cons SET :
|
||||
126 22: 4: cons SEQUENCE :
|
||||
128 3: 5: prim OBJECT_IDENTIFIER : commonName (2.5.4.3)
|
||||
133 15: 5: prim UTF8String : www.example.com
|
||||
150 42: 2: cons SEQUENCE :
|
||||
152 5: 3: cons SEQUENCE :
|
||||
154 3: 4: prim OBJECT_IDENTIFIER : ed25519 (1.3.101.112)
|
||||
159 32: 3: prim BIT_STRING :
|
||||
162 29: 4: cons EMBEDDED_PDV :
|
||||
164 26: 5: cons Private_0 :
|
||||
166 2: 6: cons Context [31] : 0b 57 |.W |
|
||||
170 19: 6: prim Context [0] : 6b ca 5e df 6e 7b 36 70 25 85 84 ca 0e f8 63 4c |k.^.n{6p%.....cL|
|
||||
: 53 64 49 |SdI |
|
||||
194 5: 1: cons SEQUENCE :
|
||||
196 3: 2: prim OBJECT_IDENTIFIER : ed25519 (1.3.101.112)
|
||||
201 64: 1: prim BIT_STRING : 20 8b bf 69 ad d0 b6 bd c8 13 9b 68 fe 7b d6 55 | ..i.......h.{.U|
|
||||
: 8f 72 dd c8 b0 1b 90 e7 03 bd 17 dc 02 d4 84 5b |.r.............[|
|
||||
: 3e 53 96 8b b5 f6 3c b0 d4 f5 36 0e f6 86 df 94 |>S....<...6.....|
|
||||
: 07 00 72 bb 37 b6 d1 4b 0b f6 a3 2c 9a 49 d0 08 |..r.7..K...,.I..|
|
||||
---
|
||||
tbsCertificate:
|
||||
version: 1
|
||||
serialNumber: "19:6e:fc:cf:0d:0e:2f:41:a9:b4:98:be:f9:af:75:74:16:bb:0e:c4"
|
||||
signature:
|
||||
algorithm: "ed25519 (1.3.101.112)"
|
||||
issuer:
|
||||
- oid: "countryName (2.5.4.6)"
|
||||
value: "DE"
|
||||
- oid: "commonName (2.5.4.3)"
|
||||
value: "www.example.com"
|
||||
validity:
|
||||
notBefore: "31/03/2019 17:51:22 GMT"
|
||||
notAfter: "28/02/2021 17:51:22 GMT"
|
||||
subject:
|
||||
- oid: "countryName (2.5.4.6)"
|
||||
value: "DE"
|
||||
- oid: "commonName (2.5.4.3)"
|
||||
value: "www.example.com"
|
||||
subjectPublicKeyInfo:
|
||||
algorithm: "ed25519 (1.3.101.112)"
|
||||
subjectPublicKey: |
|
||||
2b ce e0 d1 bf 02 0b 57 80 e6 6b ca 5e df 6e 7b +......W..k.^.n{
|
||||
36 70 25 85 84 ca 0e f8 63 4c 53 64 49 2a 09 cc 6p%.....cLSdI*..
|
||||
extensions: []
|
||||
algorithmIdentifier:
|
||||
algorithm: "ed25519 (1.3.101.112)"
|
||||
signature: |
|
||||
20 8b bf 69 ad d0 b6 bd c8 13 9b 68 fe 7b d6 55 ..i.......h.{.U
|
||||
8f 72 dd c8 b0 1b 90 e7 03 bd 17 dc 02 d4 84 5b .r.............[
|
||||
3e 53 96 8b b5 f6 3c b0 d4 f5 36 0e f6 86 df 94 >S....<...6.....
|
||||
07 00 72 bb 37 b6 d1 4b 0b f6 a3 2c 9a 49 d0 08 ..r.7..K...,.I..
|
||||
|
||||
EOF
|
||||
RUN
|
||||
|
|
|
|||
Loading…
Reference in a new issue