]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
small optimizations in ASN.1 to save memory
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 13 Sep 2012 19:31:10 +0000 (21:31 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 13 Sep 2012 19:31:10 +0000 (21:31 +0200)
lib/gnutls.asn
lib/gnutls_asn1_tab.c
lib/pkix.asn
lib/pkix_asn1_tab.c

index 64e05199b34bf9560eef1835e88ab4fe43d76240..9eaae4e1588ff6f019db030cd77aa02c2fd29973 100644 (file)
@@ -17,7 +17,7 @@ RSAPublicKey ::= SEQUENCE {
 -- CRT algorithm.
 --
 RSAPrivateKey ::= SEQUENCE {
-  version          Version,
+  version          INTEGER,
   modulus          INTEGER, -- (Usually large) n
   publicExponent   INTEGER, -- (Usually small) e
   privateExponent  INTEGER, -- (Usually large) d
@@ -29,9 +29,6 @@ RSAPrivateKey ::= SEQUENCE {
   otherPrimeInfos  OtherPrimeInfos OPTIONAL
 }
 
-Version ::= INTEGER { two-prime(0), multi(1) }
--- (CONSTRAINED BY { version must be multi if otherPrimeInfos present }) --
-
 OtherPrimeInfos ::= SEQUENCE SIZE(1..MAX) OF OtherPrimeInfo
 
 OtherPrimeInfo ::= SEQUENCE {
index 74af21df747231a6ce066e302ca20681482f812f..1079523cf4a87c64d336184e7980101636054dac 100644 (file)
@@ -11,7 +11,7 @@ const ASN1_ARRAY_TYPE gnutls_asn1_tab[] = {
   { "modulus", 1073741827, NULL },
   { "publicExponent", 3, NULL },
   { "RSAPrivateKey", 1610612741, NULL },
-  { "version", 1073741826, "Version"},
+  { "version", 1073741827, NULL },
   { "modulus", 1073741827, NULL },
   { "publicExponent", 1073741827, NULL },
   { "privateExponent", 1073741827, NULL },
@@ -21,9 +21,6 @@ const ASN1_ARRAY_TYPE gnutls_asn1_tab[] = {
   { "exponent2", 1073741827, NULL },
   { "coefficient", 1073741827, NULL },
   { "otherPrimeInfos", 16386, "OtherPrimeInfos"},
-  { "Version", 1610874883, NULL },
-  { "two-prime", 1073741825, "0"},
-  { "multi", 1, "1"},
   { "OtherPrimeInfos", 1612709899, NULL },
   { "MAX", 1074266122, "1"},
   { NULL, 2, "OtherPrimeInfo"},
index 59919aecba6026ce37d0b6620be0f63c04c0ae8a..d892c260e6a9f94704c46ddf16d8e63758566ebf 100644 (file)
@@ -214,7 +214,7 @@ Certificate  ::=  SEQUENCE  {
      signature            BIT STRING  }
 
 TBSCertificate  ::=  SEQUENCE  {
-     version         [0]  EXPLICIT Version DEFAULT v1,
+     version         [0]  EXPLICIT INTEGER DEFAULT 0,
      serialNumber         CertificateSerialNumber,
      signature            AlgorithmIdentifier,
      issuer               Name,
@@ -229,8 +229,6 @@ TBSCertificate  ::=  SEQUENCE  {
                           -- If present, version shall be v3 --  
 }
 
-Version  ::=  INTEGER  {  v1(0), v2(1), v3(2)  }
-
 CertificateSerialNumber  ::=  INTEGER
 
 Validity ::= SEQUENCE {
@@ -265,7 +263,7 @@ CertificateList  ::=  SEQUENCE  {
      signature            BIT STRING  }
 
 TBSCertList  ::=  SEQUENCE  {
-     version                 Version OPTIONAL,
+     version                 INTEGER OPTIONAL,
                                   -- if present, shall be v2
      signature               AlgorithmIdentifier,
      issuer                  Name,
@@ -356,16 +354,14 @@ pkcs-7-ContentInfo ::= SEQUENCE {
   content [0] EXPLICIT ANY DEFINED BY contentType }
 
 pkcs-7-DigestInfo ::= SEQUENCE {
-  digestAlgorithm pkcs-7-DigestAlgorithmIdentifier,
-  digest pkcs-7-Digest 
+  digestAlgorithm AlgorithmIdentifier,
+  digest OCTET STRING 
 }
 
-pkcs-7-Digest ::= OCTET STRING
-
 pkcs-7-ContentType ::= OBJECT IDENTIFIER
 
 pkcs-7-SignedData ::= SEQUENCE {
-  version pkcs-7-CMSVersion,
+  version INTEGER,
   digestAlgorithms pkcs-7-DigestAlgorithmIdentifiers,
   encapContentInfo pkcs-7-EncapsulatedContentInfo,
   certificates [0] IMPLICIT pkcs-7-CertificateSet OPTIONAL,
@@ -373,11 +369,7 @@ pkcs-7-SignedData ::= SEQUENCE {
   signerInfos pkcs-7-SignerInfos 
 }
 
-pkcs-7-CMSVersion ::= INTEGER  { v0(0), v1(1), v2(2), v3(3), v4(4) }
-
-pkcs-7-DigestAlgorithmIdentifiers ::= SET OF pkcs-7-DigestAlgorithmIdentifier
-
-pkcs-7-DigestAlgorithmIdentifier ::= AlgorithmIdentifier
+pkcs-7-DigestAlgorithmIdentifiers ::= SET OF AlgorithmIdentifier
 
 pkcs-7-EncapsulatedContentInfo ::= SEQUENCE {
   eContentType pkcs-7-ContentType,
@@ -404,7 +396,7 @@ pkcs-7-SignerInfos ::= SET OF ANY -- this is not correct but we don't use it
 
 -- Certificate requests
 pkcs-10-CertificationRequestInfo ::= SEQUENCE {
-     version       INTEGER { v1(0) },
+     version       INTEGER,
      subject       Name,
      subjectPKInfo SubjectPublicKeyInfo,
      attributes    [0] Attributes
@@ -433,15 +425,11 @@ pkcs-9-localKeyId ::= OCTET STRING
 -- Private-key information syntax
 
 pkcs-8-PrivateKeyInfo ::= SEQUENCE {
-  version pkcs-8-Version,
+  version INTEGER,
   privateKeyAlgorithm AlgorithmIdentifier,
-  privateKey pkcs-8-PrivateKey,
+  privateKey OCTET STRING,
   attributes [0] Attributes OPTIONAL }
 
-pkcs-8-Version ::= INTEGER {v1(0)}
-
-pkcs-8-PrivateKey ::= OCTET STRING
-
 pkcs-8-Attributes ::= SET OF Attribute
 
 -- Encrypted private-key information syntax
@@ -510,17 +498,9 @@ pkcs-12-SafeContents ::= SEQUENCE OF pkcs-12-SafeBag
 pkcs-12-SafeBag ::= SEQUENCE {
   bagId          OBJECT IDENTIFIER,
   bagValue       [0] EXPLICIT ANY DEFINED BY badId,
-  bagAttributes  SET OF pkcs-12-PKCS12Attribute OPTIONAL
+  bagAttributes  SET OF Attribute OPTIONAL
 }
 
--- Bag types
-
-pkcs-12-KeyBag ::= pkcs-8-PrivateKeyInfo
-
--- Shrouded KeyBag
-
-pkcs-12-PKCS8ShroudedKeyBag ::= pkcs-8-EncryptedPrivateKeyInfo
-
 -- CertBag
 
 pkcs-12-CertBag ::= SEQUENCE {
@@ -544,26 +524,22 @@ pkcs-12-SecretBag ::= SEQUENCE {
 -- x509CRL BAG-TYPE ::= {OCTET STRING IDENTIFIED BY {pkcs-9-crlTypes 1}}
 -- DER-encoded X.509 CRL stored in OCTET STRING
 
-pkcs-12-PKCS12Attribute ::= Attribute
-
 -- PKCS #7 stuff (needed in PKCS 12)
 
 pkcs-7-Data ::= OCTET STRING
 
 pkcs-7-EncryptedData ::= SEQUENCE {
-    version pkcs-7-CMSVersion,
+    version INTEGER,
     encryptedContentInfo pkcs-7-EncryptedContentInfo,
     unprotectedAttrs [1] IMPLICIT pkcs-7-UnprotectedAttributes OPTIONAL }
 
 pkcs-7-EncryptedContentInfo ::= SEQUENCE {
     contentType pkcs-7-ContentType,
     contentEncryptionAlgorithm pkcs-7-ContentEncryptionAlgorithmIdentifier,
-    encryptedContent [0] IMPLICIT pkcs-7-EncryptedContent OPTIONAL }
+    encryptedContent [0] IMPLICIT OCTET STRING OPTIONAL }
 
 pkcs-7-ContentEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
 
-pkcs-7-EncryptedContent ::= OCTET STRING
-
 pkcs-7-UnprotectedAttributes ::= SET SIZE (1..MAX) OF Attribute
 
 -- rfc3820
@@ -583,7 +559,7 @@ OCSPRequest     ::=     SEQUENCE {
     optionalSignature   [0]     EXPLICIT Signature OPTIONAL }
 
 TBSRequest      ::=     SEQUENCE {
-    version             [0] EXPLICIT Version DEFAULT v1,
+    version             [0] EXPLICIT INTEGER DEFAULT 0,
     requestorName       [1] EXPLICIT GeneralName OPTIONAL,
     requestList             SEQUENCE OF Request,
     requestExtensions   [2] EXPLICIT Extensions OPTIONAL }
@@ -593,9 +569,6 @@ Signature       ::=     SEQUENCE {
     signature            BIT STRING,
     certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
 
--- comment out, already used above, fortunately with same values and names
--- Version  ::=  INTEGER  {  v1(0) }
-
 Request ::=     SEQUENCE {
     reqCert                    CertID,
     singleRequestExtensions    [0] EXPLICIT Extensions OPTIONAL }
@@ -631,7 +604,7 @@ BasicOCSPResponse       ::= SEQUENCE {
    certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
 
 ResponseData ::= SEQUENCE {
-   version              [0] EXPLICIT Version DEFAULT v1,
+   version              [0] EXPLICIT INTEGER DEFAULT 0,
    responderID              ResponderID,
    producedAt               GeneralizedTime,
    responses                SEQUENCE OF SingleResponse,
index d5b820cb6b14978d21aabfc1050ee41aebf378bd..abd3b843b0844803e5f64aeecb03334648938422 100644 (file)
@@ -159,8 +159,8 @@ const ASN1_ARRAY_TYPE pkix_asn1_tab[] = {
   { "signatureAlgorithm", 1073741826, "AlgorithmIdentifier"},
   { "signature", 6, NULL },
   { "TBSCertificate", 1610612741, NULL },
-  { "version", 1610653698, "Version"},
-  { NULL, 1073741833, "v1"},
+  { "version", 1610653699, NULL },
+  { NULL, 1073741833, "0"},
   { NULL, 2056, "0"},
   { "serialNumber", 1073741826, "CertificateSerialNumber"},
   { "signature", 1073741826, "AlgorithmIdentifier"},
@@ -174,10 +174,6 @@ const ASN1_ARRAY_TYPE pkix_asn1_tab[] = {
   { NULL, 4104, "2"},
   { "extensions", 536895490, "Extensions"},
   { NULL, 2056, "3"},
-  { "Version", 1610874883, NULL },
-  { "v1", 1073741825, "0"},
-  { "v2", 1073741825, "1"},
-  { "v3", 1, "2"},
   { "CertificateSerialNumber", 1073741827, NULL },
   { "Validity", 1610612741, NULL },
   { "notBefore", 1073741826, "Time"},
@@ -202,7 +198,7 @@ const ASN1_ARRAY_TYPE pkix_asn1_tab[] = {
   { "signatureAlgorithm", 1073741826, "AlgorithmIdentifier"},
   { "signature", 6, NULL },
   { "TBSCertList", 1610612741, NULL },
-  { "version", 1073758210, "Version"},
+  { "version", 1073758211, NULL },
   { "signature", 1073741826, "AlgorithmIdentifier"},
   { "issuer", 1073741826, "Name"},
   { "thisUpdate", 1073741826, "Time"},
@@ -256,12 +252,11 @@ const ASN1_ARRAY_TYPE pkix_asn1_tab[] = {
   { NULL, 1073743880, "0"},
   { "contentType", 1, NULL },
   { "pkcs-7-DigestInfo", 1610612741, NULL },
-  { "digestAlgorithm", 1073741826, "pkcs-7-DigestAlgorithmIdentifier"},
-  { "digest", 2, "pkcs-7-Digest"},
-  { "pkcs-7-Digest", 1073741831, NULL },
+  { "digestAlgorithm", 1073741826, "AlgorithmIdentifier"},
+  { "digest", 7, NULL },
   { "pkcs-7-ContentType", 1073741836, NULL },
   { "pkcs-7-SignedData", 1610612741, NULL },
-  { "version", 1073741826, "pkcs-7-CMSVersion"},
+  { "version", 1073741827, NULL },
   { "digestAlgorithms", 1073741826, "pkcs-7-DigestAlgorithmIdentifiers"},
   { "encapContentInfo", 1073741826, "pkcs-7-EncapsulatedContentInfo"},
   { "certificates", 1610637314, "pkcs-7-CertificateSet"},
@@ -269,15 +264,8 @@ const ASN1_ARRAY_TYPE pkix_asn1_tab[] = {
   { "crls", 1610637314, "pkcs-7-CertificateRevocationLists"},
   { NULL, 4104, "1"},
   { "signerInfos", 2, "pkcs-7-SignerInfos"},
-  { "pkcs-7-CMSVersion", 1610874883, NULL },
-  { "v0", 1073741825, "0"},
-  { "v1", 1073741825, "1"},
-  { "v2", 1073741825, "2"},
-  { "v3", 1073741825, "3"},
-  { "v4", 1, "4"},
   { "pkcs-7-DigestAlgorithmIdentifiers", 1610612751, NULL },
-  { NULL, 2, "pkcs-7-DigestAlgorithmIdentifier"},
-  { "pkcs-7-DigestAlgorithmIdentifier", 1073741826, "AlgorithmIdentifier"},
+  { NULL, 2, "AlgorithmIdentifier"},
   { "pkcs-7-EncapsulatedContentInfo", 1610612741, NULL },
   { "eContentType", 1073741826, "pkcs-7-ContentType"},
   { "eContent", 536895495, NULL },
@@ -291,8 +279,7 @@ const ASN1_ARRAY_TYPE pkix_asn1_tab[] = {
   { "pkcs-7-SignerInfos", 1610612751, NULL },
   { NULL, 13, NULL },
   { "pkcs-10-CertificationRequestInfo", 1610612741, NULL },
-  { "version", 1610874883, NULL },
-  { "v1", 1, "0"},
+  { "version", 1073741827, NULL },
   { "subject", 1073741826, "Name"},
   { "subjectPKInfo", 1073741826, "SubjectPublicKeyInfo"},
   { "attributes", 536879106, "Attributes"},
@@ -316,14 +303,11 @@ const ASN1_ARRAY_TYPE pkix_asn1_tab[] = {
   { "utf8String", 2, "UTF8String"},
   { "pkcs-9-localKeyId", 1073741831, NULL },
   { "pkcs-8-PrivateKeyInfo", 1610612741, NULL },
-  { "version", 1073741826, "pkcs-8-Version"},
+  { "version", 1073741827, NULL },
   { "privateKeyAlgorithm", 1073741826, "AlgorithmIdentifier"},
-  { "privateKey", 1073741826, "pkcs-8-PrivateKey"},
+  { "privateKey", 1073741831, NULL },
   { "attributes", 536895490, "Attributes"},
   { NULL, 4104, "0"},
-  { "pkcs-8-Version", 1610874883, NULL },
-  { "v1", 1, "0"},
-  { "pkcs-8-PrivateKey", 1073741831, NULL },
   { "pkcs-8-Attributes", 1610612751, NULL },
   { NULL, 2, "Attribute"},
   { "pkcs-8-EncryptedPrivateKeyInfo", 1610612741, NULL },
@@ -373,9 +357,7 @@ const ASN1_ARRAY_TYPE pkix_asn1_tab[] = {
   { NULL, 1073743880, "0"},
   { "badId", 1, NULL },
   { "bagAttributes", 536887311, NULL },
-  { NULL, 2, "pkcs-12-PKCS12Attribute"},
-  { "pkcs-12-KeyBag", 1073741826, "pkcs-8-PrivateKeyInfo"},
-  { "pkcs-12-PKCS8ShroudedKeyBag", 1073741826, "pkcs-8-EncryptedPrivateKeyInfo"},
+  { NULL, 2, "Attribute"},
   { "pkcs-12-CertBag", 1610612741, NULL },
   { "certId", 1073741836, NULL },
   { "certValue", 541073421, NULL },
@@ -391,20 +373,18 @@ const ASN1_ARRAY_TYPE pkix_asn1_tab[] = {
   { "secretValue", 541073421, NULL },
   { NULL, 1073743880, "0"},
   { "secretTypeId", 1, NULL },
-  { "pkcs-12-PKCS12Attribute", 1073741826, "Attribute"},
   { "pkcs-7-Data", 1073741831, NULL },
   { "pkcs-7-EncryptedData", 1610612741, NULL },
-  { "version", 1073741826, "pkcs-7-CMSVersion"},
+  { "version", 1073741827, NULL },
   { "encryptedContentInfo", 1073741826, "pkcs-7-EncryptedContentInfo"},
   { "unprotectedAttrs", 536895490, "pkcs-7-UnprotectedAttributes"},
   { NULL, 4104, "1"},
   { "pkcs-7-EncryptedContentInfo", 1610612741, NULL },
   { "contentType", 1073741826, "pkcs-7-ContentType"},
   { "contentEncryptionAlgorithm", 1073741826, "pkcs-7-ContentEncryptionAlgorithmIdentifier"},
-  { "encryptedContent", 536895490, "pkcs-7-EncryptedContent"},
+  { "encryptedContent", 536895495, NULL },
   { NULL, 4104, "0"},
   { "pkcs-7-ContentEncryptionAlgorithmIdentifier", 1073741826, "AlgorithmIdentifier"},
-  { "pkcs-7-EncryptedContent", 1073741831, NULL },
   { "pkcs-7-UnprotectedAttributes", 1612709903, NULL },
   { "MAX", 1074266122, "1"},
   { NULL, 2, "Attribute"},
@@ -420,8 +400,8 @@ const ASN1_ARRAY_TYPE pkix_asn1_tab[] = {
   { "optionalSignature", 536895490, "Signature"},
   { NULL, 2056, "0"},
   { "TBSRequest", 1610612741, NULL },
-  { "version", 1610653698, "Version"},
-  { NULL, 1073741833, "v1"},
+  { "version", 1610653699, NULL },
+  { NULL, 1073741833, "0"},
   { NULL, 2056, "0"},
   { "requestorName", 1610637314, "GeneralName"},
   { NULL, 2056, "1"},
@@ -466,8 +446,8 @@ const ASN1_ARRAY_TYPE pkix_asn1_tab[] = {
   { NULL, 1073743880, "0"},
   { NULL, 2, "Certificate"},
   { "ResponseData", 1610612741, NULL },
-  { "version", 1610653698, "Version"},
-  { NULL, 1073741833, "v1"},
+  { "version", 1610653699, NULL },
+  { NULL, 1073741833, "0"},
   { NULL, 2056, "0"},
   { "responderID", 1073741826, "ResponderID"},
   { "producedAt", 1082130449, NULL },