asn1: Pretty-print enum values

This commit is contained in:
Nicolas Williams
2021-03-07 12:43:00 -06:00
parent be61d72be3
commit 5d7d1897de
5 changed files with 251 additions and 148 deletions

View File

@@ -241,7 +241,7 @@ In recent times the following features have been added:
"tbsCertificate": {
"_type": "TBSCertificate",
"_save": "30820376A00302010202146A0597BA71D7E6D3AC0EDC9EDC95A15B998DE40A300D06092A864886F70D01010B05003055310B3009060355040613024348311E301C060355040A131553544D6963726F656C656374726F6E696373204E56312630240603550403131D53544D2054504D20454B20496E7465726D656469617465204341203035301E170D3138313231343030303030305A170D3238313231343030303030305A300030820122300D06092A864886F70D01010105000382010F003082010A0282010100CC14EB27A78CEB0EA486FA2DF7835F5FA8E905B097012B5BDE50380C355B1A2A721BBC3D08DD21796CDB239FA95310651B1B56FD2CFE53C87352EBD996E33256160404CE9302A08066801E786A2F86E181F949966F492A85B58EAA4A6A8CB3697551BB236E87CC7BF8EC1347871C91E15437E8F266BF1EA5EB271FDCF374D8B47DF8BCE89E1FAD61C2A088CB4036B359CB72A294973FEDCCF0C340AFFD14B64F041165581ACA34147C1C75617047058F7ED7D603E032508094FA73E8B9153DA3BF255D2CBBC5DF301BA8F74D198BEBCE86040FC1D2927C7657414490D802F482F3EBF2DE35EE149A1A6DE8D16891FBFBA02A18AFE59F9D6F149744E5F0D559B10203010001A38201A9308201A5301F0603551D230418301680141ADB994AB58BE57A0CC9B900E7851E1A43C0866030420603551D20043B303930370604551D2000302F302D06082B060105050702011621687474703A2F2F7777772E73742E636F6D2F54504D2F7265706F7369746F72792F30590603551D110101FF044F304DA44B304931163014060567810502010C0B69643A353335343444323031173015060567810502020C0C53543333485450484148433031163014060567810502030C0B69643A303034393030303830670603551D090460305E301706056781050210310E300C0C03322E300201000202008A304306056781050212313A30380201000101FFA0030A0101A1030A0100A2030A0100A310300E1603332E310A01040A01020101FFA40F300D16053134302D320A0102010100300E0603551D0F0101FF040403020520300C0603551D130101FF0402300030100603551D250409300706056781050801304A06082B06010505070101043E303C303A06082B06010505073002862E687474703A2F2F7365637572652E676C6F62616C7369676E2E636F6D2F73746D74706D656B696E7430352E637274",
"version": "2",
"version": "rfc3280_version_3",
"serialNumber": "6A0597BA71D7E6D3AC0EDC9EDC95A15B998DE40A",
"signature": {
"_type": "AlgorithmIdentifier",
@@ -381,7 +381,7 @@ In recent times the following features have been added:
},
"critical": false,
"extnValue": "301680141ADB994AB58BE57A0CC9B900E7851E1A43C08660",
"_extnValue_choice": "ext-AuthorityKeyIdentifier",
"_extnValue_choice": "",
"_extnValue": {
"_type": "AuthorityKeyIdentifier",
"keyIdentifier": "1ADB994AB58BE57A0CC9B900E7851E1A43C08660",
@@ -404,7 +404,7 @@ In recent times the following features have been added:
},
"critical": false,
"extnValue": "303930370604551D2000302F302D06082B060105050702011621687474703A2F2F7777772E73742E636F6D2F54504D2F7265706F7369746F72792F",
"_extnValue_choice": "ext-CertificatePolicies",
"_extnValue_choice": "",
"_extnValue": [
{
"_type": "PolicyInformation",
@@ -460,7 +460,7 @@ In recent times the following features have been added:
},
"critical": true,
"extnValue": "304DA44B304931163014060567810502010C0B69643A353335343444323031173015060567810502020C0C53543333485450484148433031163014060567810502030C0B69643A3030343930303038",
"_extnValue_choice": "ext-SubjectAltName",
"_extnValue_choice": "",
"_extnValue": [
{
"_choice": "directoryName",
@@ -550,7 +550,7 @@ In recent times the following features have been added:
},
"critical": false,
"extnValue": "305E301706056781050210310E300C0C03322E300201000202008A304306056781050212313A30380201000101FFA0030A0101A1030A0100A2030A0100A310300E1603332E310A01040A01020101FFA40F300D16053134302D320A0102010100",
"_extnValue_choice": "ext-SubjectDirectoryAttributes",
"_extnValue_choice": "",
"_extnValue": [
{
"_type": "AttributeSet",
@@ -569,7 +569,7 @@ In recent times the following features have been added:
"values": [
"300C0C03322E300201000202008A"
],
"_values_choice": "at-TPMSpecification",
"_values_choice": "",
"_values": [
{
"_type": "TPMSpecification",
@@ -596,20 +596,20 @@ In recent times the following features have been added:
"values": [
"30380201000101FFA0030A0101A1030A0100A2030A0100A310300E1603332E310A01040A01020101FFA40F300D16053134302D320A0102010100"
],
"_values_choice": "at-TPMSecurityAssertions",
"_values_choice": "",
"_values": [
{
"_type": "TPMSecurityAssertions",
"version": "0",
"version": 0,
"fieldUpgradable": true,
"ekGenerationType": "655617",
"ekGenerationLocation": "655616",
"ekCertificateGenerationLocation": "655616",
"ekGenerationType": "ekgt_injected",
"ekGenerationLocation": "tpmManufacturer",
"ekCertificateGenerationLocation": "tpmManufacturer",
"ccInfo": {
"_type": "CommonCriteriaMeasures",
"version": "3.1",
"assurancelevel": "4",
"evaluationStatus": "2",
"assurancelevel": "ealevel4",
"evaluationStatus": "evaluationCompleted",
"plus": true,
"strengthOfFunction": null,
"profileOid": null,
@@ -620,7 +620,7 @@ In recent times the following features have been added:
"fipsLevel": {
"_type": "FIPSLevel",
"version": "140-2",
"level": "2",
"level": "sllevel2",
"plus": false
},
"iso9000Certified": false,
@@ -645,7 +645,7 @@ In recent times the following features have been added:
},
"critical": true,
"extnValue": "03020520",
"_extnValue_choice": "ext-KeyUsage",
"_extnValue_choice": "",
"_extnValue": [
"keyEncipherment"
]
@@ -665,7 +665,7 @@ In recent times the following features have been added:
},
"critical": true,
"extnValue": "3000",
"_extnValue_choice": "ext-BasicConstraints",
"_extnValue_choice": "",
"_extnValue": {
"_type": "BasicConstraints",
"cA": false,
@@ -687,7 +687,7 @@ In recent times the following features have been added:
},
"critical": false,
"extnValue": "300706056781050801",
"_extnValue_choice": "ext-ExtKeyUsage",
"_extnValue_choice": "",
"_extnValue": [
{
"_type": "OBJECT IDENTIFIER",
@@ -723,7 +723,7 @@ In recent times the following features have been added:
},
"critical": false,
"extnValue": "303C303A06082B06010505073002862E687474703A2F2F7365637572652E676C6F62616C7369676E2E636F6D2F73746D74706D656B696E7430352E637274",
"_extnValue_choice": "ext-AuthorityInfoAccess",
"_extnValue_choice": "",
"_extnValue": [
{
"_type": "AccessDescription",

View File

@@ -840,6 +840,17 @@ TypeAssignment : Identifier EEQUAL Type
s->stype = Stype;
s->type = $3;
fix_labels(s);
/*
* Hack: make sure that non-anonymous enumeration types get
* a symbol tacked on so we can generate a template for
* their members for value printing.
*/
if (s->type->type == TTag && $3->symbol == NULL &&
$3->subtype != NULL && $3->subtype->type == TInteger &&
$3->subtype->symbol == NULL) {
$3->subtype->symbol = s;
}
if (original_order)
generate_type(s);
else

View File

@@ -2212,132 +2212,133 @@ test_ios(void)
"00030100603551D250409300706056781050801304A06082B060105050701010"
"43E303C303A06082B06010505073002862E687474703A2F2F7365637572652E6"
"76C6F62616C7369676E2E636F6D2F73746D74706D656B696E7430352E637274\""
",\"version\":\"2\",\"serialNumber\":\"6A0597BA71D7E6D3AC0EDC9EDC95A15B9"
"98DE40A\",\"signature\":{\"_type\":\"AlgorithmIdentifier\",\"algorithm\":"
"{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"1.2.840.113549.1.1.11\",\"comp"
"onents\":[1,2,840,113549,1,1,11],\"name\":\"id-pkcs1-sha256WithRSAEn"
"cryption\"},\"parameters\":\"0500\"},\"issuer\":{\"_choice\":\"rdnSequence"
"\",\"value\":[[{\"_type\":\"AttributeTypeAndValue\",\"type\":{\"_type\":\"OB"
"JECT IDENTIFIER\",\"oid\":\"2.5.4.6\",\"components\":[2,5,4,6],\"name\":\""
"id-at-countryName\"},\"value\":{\"_choice\":\"printableString\",\"value\""
":\"CH\"}}],[{\"_type\":\"AttributeTypeAndValue\",\"type\":{\"_type\":\"OBJE"
"CT IDENTIFIER\",\"oid\":\"2.5.4.10\",\"components\":[2,5,4,10],\"name\":\""
"id-at-organizationName\"},\"value\":{\"_choice\":\"printableString\",\"v"
"alue\":\"STMicroelectronics NV\"}}],[{\"_type\":\"AttributeTypeAndValu"
"e\",\"type\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2.5.4.3\",\"componen"
"ts\":[2,5,4,3],\"name\":\"id-at-commonName\"},\"value\":{\"_choice\":\"pri"
"ntableString\",\"value\":\"STM TPM EK Intermediate CA 05\"}}]]},\"vali"
"dity\":{\"_type\":\"Validity\",\"notBefore\":{\"_choice\":\"utcTime\",\"valu"
"e\":\"2018-12-14T00:00:00Z\"},\"notAfter\":{\"_choice\":\"utcTime\",\"valu"
"e\":\"2028-12-14T00:00:00Z\"}},\"subject\":{\"_choice\":\"rdnSequence\",\""
"value\":[]},\"subjectPublicKeyInfo\":{\"_type\":\"SubjectPublicKeyInfo"
"\",\"algorithm\":{\"_type\":\"AlgorithmIdentifier\",\"algorithm\":{\"_type"
"\":\"OBJECT IDENTIFIER\",\"oid\":\"1.2.840.113549.1.1.1\",\"components\":"
"[1,2,840,113549,1,1,1],\"name\":\"id-pkcs1-rsaEncryption\"},\"paramet"
"ers\":\"0500\"},\"subjectPublicKey\":\"2160:3082010A0282010100CC14EB27"
"A78CEB0EA486FA2DF7835F5FA8E905B097012B5BDE50380C355B1A2A721BBC3D"
"08DD21796CDB239FA95310651B1B56FD2CFE53C87352EBD996E33256160404CE"
"9302A08066801E786A2F86E181F949966F492A85B58EAA4A6A8CB3697551BB23"
"6E87CC7BF8EC1347871C91E15437E8F266BF1EA5EB271FDCF374D8B47DF8BCE8"
"9E1FAD61C2A088CB4036B359CB72A294973FEDCCF0C340AFFD14B64F04116558"
"1ACA34147C1C75617047058F7ED7D603E032508094FA73E8B9153DA3BF255D2C"
"BBC5DF301BA8F74D198BEBCE86040FC1D2927C7657414490D802F482F3EBF2DE"
"35EE149A1A6DE8D16891FBFBA02A18AFE59F9D6F149744E5F0D559B102030100"
"01\"},\"issuerUniqueID\":null,\"subjectUniqueID\":null,\"extensions\":["
",\"version\":\"rfc3280_version_3\",\"serialNumber\":\"6A0597BA71D7E6D3A"
"C0EDC9EDC95A15B998DE40A\",\"signature\":{\"_type\":\"AlgorithmIdentifi"
"er\",\"algorithm\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"1.2.840.1135"
"49.1.1.11\",\"components\":[1,2,840,113549,1,1,11],\"name\":\"id-pkcs1"
"-sha256WithRSAEncryption\"},\"parameters\":\"0500\"},\"issuer\":{\"_choi"
"ce\":\"rdnSequence\",\"value\":[[{\"_type\":\"AttributeTypeAndValue\",\"ty"
"pe\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2.5.4.6\",\"components\":[2"
",5,4,6],\"name\":\"id-at-countryName\"},\"value\":{\"_choice\":\"printabl"
"eString\",\"value\":\"CH\"}}],[{\"_type\":\"AttributeTypeAndValue\",\"type"
"\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2.5.4.10\",\"components\":[2,"
"5,4,10],\"name\":\"id-at-organizationName\"},\"value\":{\"_choice\":\"pri"
"ntableString\",\"value\":\"STMicroelectronics NV\"}}],[{\"_type\":\"Attr"
"ibuteTypeAndValue\",\"type\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2."
"5.4.3\",\"components\":[2,5,4,3],\"name\":\"id-at-commonName\"},\"value\""
":{\"_choice\":\"printableString\",\"value\":\"STM TPM EK Intermediate C"
"A 05\"}}]]},\"validity\":{\"_type\":\"Validity\",\"notBefore\":{\"_choice\""
":\"utcTime\",\"value\":\"2018-12-14T00:00:00Z\"},\"notAfter\":{\"_choice\""
":\"utcTime\",\"value\":\"2028-12-14T00:00:00Z\"}},\"subject\":{\"_choice\""
":\"rdnSequence\",\"value\":[]},\"subjectPublicKeyInfo\":{\"_type\":\"Subj"
"ectPublicKeyInfo\",\"algorithm\":{\"_type\":\"AlgorithmIdentifier\",\"al"
"gorithm\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"1.2.840.113549.1.1."
"1\",\"components\":[1,2,840,113549,1,1,1],\"name\":\"id-pkcs1-rsaEncry"
"ption\"},\"parameters\":\"0500\"},\"subjectPublicKey\":\"2160:3082010A02"
"82010100CC14EB27A78CEB0EA486FA2DF7835F5FA8E905B097012B5BDE50380C"
"355B1A2A721BBC3D08DD21796CDB239FA95310651B1B56FD2CFE53C87352EBD9"
"96E33256160404CE9302A08066801E786A2F86E181F949966F492A85B58EAA4A"
"6A8CB3697551BB236E87CC7BF8EC1347871C91E15437E8F266BF1EA5EB271FDC"
"F374D8B47DF8BCE89E1FAD61C2A088CB4036B359CB72A294973FEDCCF0C340AF"
"FD14B64F041165581ACA34147C1C75617047058F7ED7D603E032508094FA73E8"
"B9153DA3BF255D2CBBC5DF301BA8F74D198BEBCE86040FC1D2927C7657414490"
"D802F482F3EBF2DE35EE149A1A6DE8D16891FBFBA02A18AFE59F9D6F149744E5"
"F0D559B10203010001\"},\"issuerUniqueID\":null,\"subjectUniqueID\":nul"
"l,\"extensions\":[{\"_type\":\"Extension\",\"extnID\":{\"_type\":\"OBJECT I"
"DENTIFIER\",\"oid\":\"2.5.29.35\",\"components\":[2,5,29,35],\"name\":\"id"
"-x509-ce-authorityKeyIdentifier\"},\"critical\":false,\"extnValue\":\""
"301680141ADB994AB58BE57A0CC9B900E7851E1A43C08660\",\"_extnValue_ch"
"oice\":\"\",\"_extnValue\":{\"_type\":\"AuthorityKeyIdentifier\",\"keyIden"
"tifier\":\"1ADB994AB58BE57A0CC9B900E7851E1A43C08660\",\"authorityCer"
"tIssuer\":null,\"authorityCertSerialNumber\":null}},{\"_type\":\"Exten"
"sion\",\"extnID\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2.5.29.32\",\"c"
"omponents\":[2,5,29,32],\"name\":\"id-x509-ce-certificatePolicies\"},"
"\"critical\":false,\"extnValue\":\"303930370604551D2000302F302D06082B"
"060105050702011621687474703A2F2F7777772E73742E636F6D2F54504D2F72"
"65706F7369746F72792F\",\"_extnValue_choice\":\"\",\"_extnValue\":[{\"_ty"
"pe\":\"PolicyInformation\",\"policyIdentifier\":{\"_type\":\"OBJECT IDEN"
"TIFIER\",\"oid\":\"2.5.29.32.0\",\"components\":[2,5,29,32,0],\"name\":\"i"
"d-x509-ce-certificatePolicies-anyPolicy\"},\"policyQualifiers\":[{\""
"_type\":\"PolicyQualifierInfo\",\"policyQualifierId\":{\"_type\":\"OBJEC"
"T IDENTIFIER\",\"oid\":\"1.3.6.1.5.5.7.2.1\",\"components\":[1,3,6,1,5,"
"5,7,2,1],\"name\":\"id-pkix-qt-cps\"},\"qualifier\":\"1621687474703A2F2"
"F7777772E73742E636F6D2F54504D2F7265706F7369746F72792F\"}]}]},{\"_t"
"ype\":\"Extension\",\"extnID\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2."
"5.29.17\",\"components\":[2,5,29,17],\"name\":\"id-x509-ce-subjectAltN"
"ame\"},\"critical\":true,\"extnValue\":\"304DA44B304931163014060567810"
"502010C0B69643A353335343444323031173015060567810502020C0C5354333"
"3485450484148433031163014060567810502030C0B69643A303034393030303"
"8\",\"_extnValue_choice\":\"\",\"_extnValue\":[{\"_choice\":\"directoryNam"
"e\",\"value\":{\"_choice\":\"rdnSequence\",\"value\":[[{\"_type\":\"Attribut"
"eTypeAndValue\",\"type\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2.23.1"
"33.2.1\",\"components\":[2,23,133,2,1],\"name\":\"tcg-at-tpmManufactur"
"er\"},\"value\":{\"_choice\":\"utf8String\",\"value\":\"id:53544D20\"}}],[{"
"\"_type\":\"AttributeTypeAndValue\",\"type\":{\"_type\":\"OBJECT IDENTIFI"
"ER\",\"oid\":\"2.23.133.2.2\",\"components\":[2,23,133,2,2],\"name\":\"tcg"
"-at-tpmModel\"},\"value\":{\"_choice\":\"utf8String\",\"value\":\"ST33HTPH"
"AHC0\"}}],[{\"_type\":\"AttributeTypeAndValue\",\"type\":{\"_type\":\"OBJE"
"CT IDENTIFIER\",\"oid\":\"2.23.133.2.3\",\"components\":[2,23,133,2,3],"
"\"name\":\"tcg-at-tpmVersion\"},\"value\":{\"_choice\":\"utf8String\",\"val"
"ue\":\"id:00490008\"}}]]}}]},{\"_type\":\"Extension\",\"extnID\":{\"_type\""
":\"OBJECT IDENTIFIER\",\"oid\":\"2.5.29.9\",\"components\":[2,5,29,9],\"n"
"ame\":\"id-x509-ce-subjectDirectoryAttributes\"},\"critical\":false,\""
"extnValue\":\"305E301706056781050210310E300C0C03322E30020100020200"
"8A304306056781050212313A30380201000101FFA0030A0101A1030A0100A203"
"0A0100A310300E1603332E310A01040A01020101FFA40F300D16053134302D32"
"0A0102010100\",\"_extnValue_choice\":\"\",\"_extnValue\":[{\"_type\":\"Att"
"ributeSet\",\"type\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2.23.133.2"
".16\",\"components\":[2,23,133,2,16],\"name\":\"tcg-at-tpmSpecificatio"
"n\"},\"values\":[\"300C0C03322E300201000202008A\"],\"_values_choice\":\""
"\",\"_values\":[{\"_type\":\"TPMSpecification\",\"family\":\"2.0\",\"level\":"
"0,\"revision\":138}]},{\"_type\":\"AttributeSet\",\"type\":{\"_type\":\"OBJ"
"ECT IDENTIFIER\",\"oid\":\"2.23.133.2.18\",\"components\":[2,23,133,2,1"
"8],\"name\":\"tcg-at-tpmSecurityAssertions\"},\"values\":[\"30380201000"
"101FFA0030A0101A1030A0100A2030A0100A310300E1603332E310A01040A010"
"20101FFA40F300D16053134302D320A0102010100\"],\"_values_choice\":\"\","
"\"_values\":[{\"_type\":\"TPMSecurityAssertions\",\"version\":0,\"fieldUp"
"gradable\":true,\"ekGenerationType\":\"ekgt_injected\",\"ekGenerationL"
"ocation\":\"tpmManufacturer\",\"ekCertificateGenerationLocation\":\"tp"
"mManufacturer\",\"ccInfo\":{\"_type\":\"CommonCriteriaMeasures\",\"versi"
"on\":\"3.1\",\"assurancelevel\":\"ealevel4\",\"evaluationStatus\":\"evalua"
"tionCompleted\",\"plus\":true,\"strengthOfFunction\":null,\"profileOid"
"\":null,\"profileUri\":null,\"targetOid\":null,\"targetUri\":null},\"fip"
"sLevel\":{\"_type\":\"FIPSLevel\",\"version\":\"140-2\",\"level\":\"sllevel2"
"\",\"plus\":false},\"iso9000Certified\":false,\"iso9000Uri\":null}]}]},"
"{\"_type\":\"Extension\",\"extnID\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\""
":\"2.5.29.35\",\"components\":[2,5,29,35],\"name\":\"id-x509-ce-authori"
"tyKeyIdentifier\"},\"critical\":false,\"extnValue\":\"301680141ADB994A"
"B58BE57A0CC9B900E7851E1A43C08660\",\"_extnValue_choice\":\"\",\"_extnV"
"alue\":{\"_type\":\"AuthorityKeyIdentifier\",\"keyIdentifier\":\"1ADB994"
"AB58BE57A0CC9B900E7851E1A43C08660\",\"authorityCertIssuer\":null,\"a"
"uthorityCertSerialNumber\":null}},{\"_type\":\"Extension\",\"extnID\":{"
"\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2.5.29.32\",\"components\":[2,5,"
"29,32],\"name\":\"id-x509-ce-certificatePolicies\"},\"critical\":false"
",\"extnValue\":\"303930370604551D2000302F302D06082B0601050507020116"
"21687474703A2F2F7777772E73742E636F6D2F54504D2F7265706F7369746F72"
"792F\",\"_extnValue_choice\":\"\",\"_extnValue\":[{\"_type\":\"PolicyInfor"
"mation\",\"policyIdentifier\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2"
".5.29.32.0\",\"components\":[2,5,29,32,0],\"name\":\"id-x509-ce-certif"
"icatePolicies-anyPolicy\"},\"policyQualifiers\":[{\"_type\":\"PolicyQu"
"alifierInfo\",\"policyQualifierId\":{\"_type\":\"OBJECT IDENTIFIER\",\"o"
"id\":\"1.3.6.1.5.5.7.2.1\",\"components\":[1,3,6,1,5,5,7,2,1],\"name\":"
"\"id-pkix-qt-cps\"},\"qualifier\":\"1621687474703A2F2F7777772E73742E6"
"36F6D2F54504D2F7265706F7369746F72792F\"}]}]},{\"_type\":\"Extension\""
",\"extnID\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2.5.29.17\",\"compon"
"ents\":[2,5,29,17],\"name\":\"id-x509-ce-subjectAltName\"},\"critical\""
":true,\"extnValue\":\"304DA44B304931163014060567810502010C0B69643A3"
"53335343444323031173015060567810502020C0C53543333485450484148433"
"031163014060567810502030C0B69643A3030343930303038\",\"_extnValue_c"
"hoice\":\"\",\"_extnValue\":[{\"_choice\":\"directoryName\",\"value\":{\"_ch"
"oice\":\"rdnSequence\",\"value\":[[{\"_type\":\"AttributeTypeAndValue\",\""
"type\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2.23.133.2.1\",\"compone"
"nts\":[2,23,133,2,1],\"name\":\"tcg-at-tpmManufacturer\"},\"value\":{\"_"
"choice\":\"utf8String\",\"value\":\"id:53544D20\"}}],[{\"_type\":\"Attribu"
"teTypeAndValue\",\"type\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2.23."
"133.2.2\",\"components\":[2,23,133,2,2],\"name\":\"tcg-at-tpmModel\"},\""
"value\":{\"_choice\":\"utf8String\",\"value\":\"ST33HTPHAHC0\"}}],[{\"_typ"
"e\":\"AttributeTypeAndValue\",\"type\":{\"_type\":\"OBJECT IDENTIFIER\",\""
"oid\":\"2.23.133.2.3\",\"components\":[2,23,133,2,3],\"name\":\"tcg-at-t"
"pmVersion\"},\"value\":{\"_choice\":\"utf8String\",\"value\":\"id:00490008"
"\"}}]]}}]},{\"_type\":\"Extension\",\"extnID\":{\"_type\":\"OBJECT IDENTIF"
"IER\",\"oid\":\"2.5.29.9\",\"components\":[2,5,29,9],\"name\":\"id-x509-ce"
"-subjectDirectoryAttributes\"},\"critical\":false,\"extnValue\":\"305E"
"301706056781050210310E300C0C03322E300201000202008A30430605678105"
"0212313A30380201000101FFA0030A0101A1030A0100A2030A0100A310300E16"
"03332E310A01040A01020101FFA40F300D16053134302D320A0102010100\",\"_"
"extnValue_choice\":\"\",\"_extnValue\":[{\"_type\":\"AttributeSet\",\"type"
"\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2.23.133.2.16\",\"components"
"\":[2,23,133,2,16],\"name\":\"tcg-at-tpmSpecification\"},\"values\":[\"3"
"00C0C03322E300201000202008A\"],\"_values_choice\":\"\",\"_values\":[{\"_"
"type\":\"TPMSpecification\",\"family\":\"2.0\",\"level\":0,\"revision\":138"
"}]},{\"_type\":\"AttributeSet\",\"type\":{\"_type\":\"OBJECT IDENTIFIER\","
"\"oid\":\"2.23.133.2.18\",\"components\":[2,23,133,2,18],\"name\":\"tcg-a"
"t-tpmSecurityAssertions\"},\"values\":[\"30380201000101FFA0030A0101A"
"1030A0100A2030A0100A310300E1603332E310A01040A01020101FFA40F300D1"
"6053134302D320A0102010100\"],\"_values_choice\":\"\",\"_values\":[{\"_ty"
"pe\":\"TPMSecurityAssertions\",\"version\":\"0\",\"fieldUpgradable\":true"
",\"ekGenerationType\":\"1\",\"ekGenerationLocation\":\"0\",\"ekCertificat"
"eGenerationLocation\":\"0\",\"ccInfo\":{\"_type\":\"CommonCriteriaMeasur"
"es\",\"version\":\"3.1\",\"assurancelevel\":\"4\",\"evaluationStatus\":\"2\","
"\"plus\":true,\"strengthOfFunction\":null,\"profileOid\":null,\"profile"
"Uri\":null,\"targetOid\":null,\"targetUri\":null},\"fipsLevel\":{\"_type"
"\":\"FIPSLevel\",\"version\":\"140-2\",\"level\":\"2\",\"plus\":false},\"iso90"
"00Certified\":false,\"iso9000Uri\":null}]}]},{\"_type\":\"Extension\",\""
"extnID\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2.5.29.15\",\"componen"
"ts\":[2,5,29,15],\"name\":\"id-x509-ce-keyUsage\"},\"critical\":true,\"e"
"xtnValue\":\"03020520\",\"_extnValue_choice\":\"\",\"_extnValue\":[\"keyEn"
"cipherment\"]},{\"_type\":\"Extension\",\"extnID\":{\"_type\":\"OBJECT IDE"
"NTIFIER\",\"oid\":\"2.5.29.19\",\"components\":[2,5,29,19],\"name\":\"id-x"
"509-ce-basicConstraints\"},\"critical\":true,\"extnValue\":\"3000\",\"_e"
"xtnValue_choice\":\"\",\"_extnValue\":{\"_type\":\"BasicConstraints\",\"cA"
"\":false,\"pathLenConstraint\":null}},{\"_type\":\"Extension\",\"extnID\""
":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2.5.29.37\",\"components\":[2,"
"5,29,37],\"name\":\"id-x509-ce-extKeyUsage\"},\"critical\":false,\"extn"
"Value\":\"300706056781050801\",\"_extnValue_choice\":\"\",\"_extnValue\":"
"[{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2.23.133.8.1\",\"components\":"
"[2,23,133,8,1],\"name\":\"tcg-kp-EKCertificate\"}]},{\"_type\":\"Extens"
"ion\",\"extnID\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"1.3.6.1.5.5.7."
"1.1\",\"components\":[1,3,6,1,5,5,7,1,1],\"name\":\"id-pkix-pe-authori"
"tyInfoAccess\"},\"critical\":false,\"extnValue\":\"303C303A06082B06010"
"505073002862E687474703A2F2F7365637572652E676C6F62616C7369676E2E6"
"36F6D2F73746D74706D656B696E7430352E637274\",\"_extnValue_choice\":\""
"\",\"_extnValue\":[{\"_type\":\"AccessDescription\",\"accessMethod\":{\"_t"
"ype\":\"OBJECT IDENTIFIER\",\"oid\":\"1.3.6.1.5.5.7.48.2\",\"components\""
":[1,3,6,1,5,5,7,48,2],\"name\":\"id-pkix-ad-caIssuers\"},\"accessLoca"
"tion\":{\"_choice\":\"uniformResourceIdentifier\",\"value\":\"http://sec"
"ure.globalsign.com/stmtpmekint05.crt\"}}]}]},\"signatureAlgorithm\""
":{\"_type\":\"AlgorithmIdentifier\",\"algorithm\":{\"_type\":\"OBJECT IDE"
"NTIFIER\",\"oid\":\"1.2.840.113549.1.1.11\",\"components\":[1,2,840,113"
"549,1,1,11],\"name\":\"id-pkcs1-sha256WithRSAEncryption\"},\"paramete"
"rs\":\"0500\"},\"signatureValue\":\"2048:3D4C381E5B4F1BCBE09C63D52F1F0"
"4570CAEA142FD9CD942043B11F8E3BDCF50007AE16CF8869013041E92CDD3280"
"BA4B51FBBD40582ED750219E261A695095674855AACEB520ADAFF9E7E908480A"
"39CDCF900462D9171960FFE55D3AC49E8C981341BBD2EFBCC252A4C18A4F3B7C"
"84CCE42CE70A208C84D2630A7ABFBE72D6271E75B9FF1C971D20EB3DBD763F1E"
"04D834EAA692D2E4001BBF4730A3E3FDA9711AE386524D91C63BE0E516D00D5C"
"6141FCCF6C539F3518E180049865BE16B69CAE1F8CB7FDC474B38F7EE56CBE7D"
"8A89D9BA99B65D5265AEF32AA62426B10E6D75BB8677EC44F755BBC2806FD2B4"
"E04BDF5D44259DBEAA42B6F563DF7AA7506\"}"
":\"2.5.29.15\",\"components\":[2,5,29,15],\"name\":\"id-x509-ce-keyUsag"
"e\"},\"critical\":true,\"extnValue\":\"03020520\",\"_extnValue_choice\":\""
"\",\"_extnValue\":[\"keyEncipherment\"]},{\"_type\":\"Extension\",\"extnID"
"\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2.5.29.19\",\"components\":[2"
",5,29,19],\"name\":\"id-x509-ce-basicConstraints\"},\"critical\":true,"
"\"extnValue\":\"3000\",\"_extnValue_choice\":\"\",\"_extnValue\":{\"_type\":"
"\"BasicConstraints\",\"cA\":false,\"pathLenConstraint\":null}},{\"_type"
"\":\"Extension\",\"extnID\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2.5.2"
"9.37\",\"components\":[2,5,29,37],\"name\":\"id-x509-ce-extKeyUsage\"},"
"\"critical\":false,\"extnValue\":\"300706056781050801\",\"_extnValue_ch"
"oice\":\"\",\"_extnValue\":[{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"2.23."
"133.8.1\",\"components\":[2,23,133,8,1],\"name\":\"tcg-kp-EKCertificat"
"e\"}]},{\"_type\":\"Extension\",\"extnID\":{\"_type\":\"OBJECT IDENTIFIER\""
",\"oid\":\"1.3.6.1.5.5.7.1.1\",\"components\":[1,3,6,1,5,5,7,1,1],\"nam"
"e\":\"id-pkix-pe-authorityInfoAccess\"},\"critical\":false,\"extnValue"
"\":\"303C303A06082B06010505073002862E687474703A2F2F7365637572652E6"
"76C6F62616C7369676E2E636F6D2F73746D74706D656B696E7430352E637274\""
",\"_extnValue_choice\":\"\",\"_extnValue\":[{\"_type\":\"AccessDescriptio"
"n\",\"accessMethod\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"1.3.6.1.5."
"5.7.48.2\",\"components\":[1,3,6,1,5,5,7,48,2],\"name\":\"id-pkix-ad-c"
"aIssuers\"},\"accessLocation\":{\"_choice\":\"uniformResourceIdentifie"
"r\",\"value\":\"http://secure.globalsign.com/stmtpmekint05.crt\"}}]}]"
"},\"signatureAlgorithm\":{\"_type\":\"AlgorithmIdentifier\",\"algorithm"
"\":{\"_type\":\"OBJECT IDENTIFIER\",\"oid\":\"1.2.840.113549.1.1.11\",\"co"
"mponents\":[1,2,840,113549,1,1,11],\"name\":\"id-pkcs1-sha256WithRSA"
"Encryption\"},\"parameters\":\"0500\"},\"signatureValue\":\"2048:3D4C381"
"E5B4F1BCBE09C63D52F1F04570CAEA142FD9CD942043B11F8E3BDCF50007AE16"
"CF8869013041E92CDD3280BA4B51FBBD40582ED750219E261A695095674855AA"
"CEB520ADAFF9E7E908480A39CDCF900462D9171960FFE55D3AC49E8C981341BB"
"D2EFBCC252A4C18A4F3B7C84CCE42CE70A208C84D2630A7ABFBE72D6271E75B9"
"FF1C971D20EB3DBD763F1E04D834EAA692D2E4001BBF4730A3E3FDA9711AE386"
"524D91C63BE0E516D00D5C6141FCCF6C539F3518E180049865BE16B69CAE1F8C"
"B7FDC474B38F7EE56CBE7D8A89D9BA99B65D5265AEF32AA62426B10E6D75BB86"
"77EC44F755BBC2806FD2B4E04BDF5D44259DBEAA42B6F563DF7AA7506\"}"
};
heim_octet_string os;
Certificate c0, c1;

View File

@@ -432,7 +432,7 @@ add_line(struct templatehead *t, const char *fmt, ...)
}
/*
* Add an entry to a template, with the pointer field bein a symbol name of a
* Add an entry to a template, with the pointer field being a symbol name of a
* template (i.e., an array, which decays to a pointer as usual in C).
*/
static void
@@ -457,6 +457,9 @@ add_line_pointer(struct templatehead *t,
q->ptr = strdup(ptr);
}
/*
* Add an entry to a template where the pointer firled is a string literal.
*/
static void
add_line_string(struct templatehead *t,
const char *str,
@@ -479,6 +482,10 @@ add_line_string(struct templatehead *t,
q->ptr = strdup(str);
}
/*
* Add an entry to a template, with the pointer field being a reference to
* named object of a type other than a template or other array type.
*/
static void
add_line_pointer_reference(struct templatehead *t,
const char *ptr,
@@ -904,6 +911,7 @@ template_members(struct templatehead *temp,
break;
case TEnumerated:
case TInteger: {
char *varname = NULL;
char *itype = NULL;
if (t->members)
@@ -922,7 +930,49 @@ template_members(struct templatehead *temp,
errx(1, "%s: unsupported range %lld -> %lld",
name, (long long)t->range->min, (long long)t->range->max);
add_line(temp, "{ A1_PARSE_T(A1T_%s), %s, NULL }", itype, poffset);
/*
* If `t->members' then we should generate a template for those
* members.
*
* We don't know the name of this field, and the type may not have a
* name. If it has no name, we should generate a name for it, and if
* it does have a name, use it, to name a template for its members.
*
* Then we could use that in _asn1_print() to pretty-print values of
* enumerations.
*/
if (t->members && t->symbol) {
struct tlist *tl;
Member *m;
size_t nmemb = 0;
if (asprintf(&varname, "%s_enum_names", t->symbol->gen_name) == -1 ||
varname == NULL)
err(1, "Out of memory");
tl = tlist_new(varname);
/*
* XXX We're going to assume that t->members is sorted in
* numerically ascending order in the module source. We should
* really sort it here.
*/
HEIM_TAILQ_FOREACH(m, t->members, members) {
if (m->val > UINT32_MAX)
continue; /* Wouldn't fit in the offset field */
add_line(&tl->template,
"{ A1_OP_NAME, %d, \"%s\" }", m->val, m->gen_name);
nmemb++;
}
tlist_header(tl, "{ 0, 0, ((void *)%lu) }", nmemb);
/* XXX Accidentally O(N^2)? */
if (!tlist_find_dup(tl)) {
tlist_print(tl);
tlist_add(tl);
}
add_line(temp, "{ A1_PARSE_T(A1T_%s), %s, asn1_%s }", itype, poffset, varname);
} else {
add_line(temp, "{ A1_PARSE_T(A1T_%s), %s, NULL }", itype, poffset);
}
break;
}
case TGeneralString:

View File

@@ -230,7 +230,11 @@ typeid_int_cmp(const void *intp,
if ((tint[1].tt & A1_OP_MASK) != A1_OP_PARSE)
return -1;
if (A1_PARSE_TYPE(tint[1].tt) != A1T_INTEGER)
if (A1_PARSE_TYPE(tint[1].tt) != A1T_INTEGER &&
A1_PARSE_TYPE(tint[1].tt) != A1T_UNSIGNED &&
A1_PARSE_TYPE(tint[1].tt) != A1T_INTEGER64 &&
A1_PARSE_TYPE(tint[1].tt) != A1T_UNSIGNED64 &&
A1_PARSE_TYPE(tint[1].tt) != A1T_IMEMBER)
return -1;
switch (tint[0].offset) {
case 8: return i - *(const int64_t *)intp;
@@ -510,8 +514,12 @@ _asn1_decode_open_type(const struct asn1_template *t,
if ((tint->tt & A1_OP_MASK) != A1_OP_PARSE)
return 0; /* Do nothing, silently */
if (A1_PARSE_TYPE(tint->tt) != A1T_INTEGER)
return 0; /* Do nothing, silently (probably a large int) */
if (A1_PARSE_TYPE(tint->tt) != A1T_INTEGER &&
A1_PARSE_TYPE(tint->tt) != A1T_UNSIGNED &&
A1_PARSE_TYPE(tint->tt) != A1T_INTEGER64 &&
A1_PARSE_TYPE(tint->tt) != A1T_UNSIGNED64 &&
A1_PARSE_TYPE(tint->tt) != A1T_IMEMBER)
return 0; /* Do nothing, silently (maybe a large int) */
typeid_is_int = 1;
break;
}
@@ -2564,9 +2572,42 @@ _asn1_print(const struct asn1_template *t,
ABORT_ON_ERROR();
break;
}
if (type == A1T_IMEMBER && t->ptr) {
/* Enumeration. Use the symbolic name of this value */
const struct asn1_template *tenum = t->ptr;
size_t left = 0;
size_t right = A1_HEADER_LEN(tenum);
size_t mid;
uint32_t v = *(unsigned int *)el;
int c = -1;
while (left <= right) {
mid = (left + right) >> 1;
if ((tenum[mid].tt & A1_OP_MASK) != A1_OP_NAME)
break;
c = v - tenum[mid].offset;
if (c < 0) {
if (mid)
right = mid - 1;
else
break;
} else if (c > 0) {
left = mid + 1;
} else {
break;
}
}
if (c == 0) {
r = rk_strpoolprintf(r, "\"%s\"", (const char *)tenum[mid].ptr);
break;
}
}
s = (asn1_template_prim[type].print)(el, flags);
switch (type) {
case A1T_OID:
case A1T_IMEMBER:
case A1T_BOOLEAN:
case A1T_INTEGER:
case A1T_INTEGER64: