|
|
1.1 ! root 1: -- af-dec.py - manually-augmented AuthenticationFramework module ! 2: ! 3: -- $Header: /f/osi/dsap/x500as/RCS/af-dec.py,v 7.0 89/11/23 21:50:01 mrose Rel $ ! 4: -- ! 5: -- ! 6: -- $Log: af-dec.py,v $ ! 7: -- Revision 7.0 89/11/23 21:50:01 mrose ! 8: -- Release 6.0 ! 9: -- ! 10: ! 11: -- ! 12: -- NOTICE ! 13: -- ! 14: -- Acquisition, use, and distribution of this module and related ! 15: -- materials are subject to the restrictions of a license agreement. ! 16: -- Consult the Preface in the User's Manual for the full terms of ! 17: -- this agreement. ! 18: -- ! 19: -- ! 20: ! 21: ! 22: AF ! 23: { ! 24: joint-iso-ccitt ! 25: ds(5) ! 26: modules(1) ! 27: authenticationFramework(7) ! 28: } ! 29: ! 30: DEFINITIONS ::= ! 31: ! 32: %{ ! 33: #include <stdio.h> ! 34: #include "quipu/util.h" ! 35: #include "quipu/name.h" ! 36: #include "quipu/bind.h" ! 37: ! 38: #define decode_UNIV_UTCTime parse_UNIV_UTCTime ! 39: ! 40: extern LLog * log_dsap; ! 41: %} ! 42: ! 43: PREFIXES encode decode print ! 44: ! 45: BEGIN ! 46: ! 47: -- EXPORTS ! 48: -- AlgorithmIdentifier , ! 49: -- Certificate , ! 50: -- Certificates , ! 51: -- CertificationPath; ! 52: ! 53: IMPORTS ! 54: Name ! 55: FROM IF ! 56: { ! 57: joint-iso-ccitt ! 58: ds(5) ! 59: modules(1) ! 60: informationFramework(1) ! 61: }; ! 62: ! 63: DECODER decode ! 64: ! 65: Version [[P int *]] ! 66: ::= ! 67: %{ ! 68: DLOG(log_dsap, LLOG_TRACE, ("At decode Version (AF)")); ! 69: %} ! 70: INTEGER [[i *parm]] ! 71: %{ ! 72: DLOG(log_dsap, LLOG_TRACE, ("Done decode Version (AF)")); ! 73: %} ! 74: ! 75: CertificateSerialNumber [[P int *]] ! 76: ::= ! 77: %{ ! 78: DLOG(log_dsap, LLOG_TRACE, ("About to decode CertificateSerialNumber (AF)")); ! 79: %} ! 80: INTEGER [[i *parm]] ! 81: %{ ! 82: DLOG(log_dsap, LLOG_TRACE, ("Done decode CertificateSerialNumber (AF)")); ! 83: %} ! 84: ! 85: Validity [[P struct validity *]] ! 86: ::= ! 87: %{ ! 88: DLOG(log_dsap, LLOG_TRACE, ("About to decode Validity (AF)")); ! 89: %} ! 90: SEQUENCE ! 91: { ! 92: notBefore ! 93: UTCTime [[s parm->not_before]], ! 94: notAfter ! 95: UTCTime [[s parm->not_after]] ! 96: } ! 97: %{ ! 98: DLOG(log_dsap, LLOG_TRACE, ("Done decode Validity (AF)")); ! 99: %} ! 100: ! 101: AlgorithmIdentifier [[P struct alg_id *]] ! 102: ::= ! 103: %{ ! 104: DLOG(log_dsap, LLOG_TRACE, ("About to decode AlgorithmIdentifier (AF)")); ! 105: parm->p_type = ALG_PARM_ABSENT; ! 106: parm->un.numeric = 0; ! 107: %} ! 108: SEQUENCE ! 109: { ! 110: algorithm ! 111: OBJECT IDENTIFIER [[O parm->algorithm]], ! 112: parameters ! 113: ANY [[a parm->asn]] ! 114: %{ ! 115: parm->p_type = ALG_PARM_UNKNOWN; ! 116: %} ! 117: OPTIONAL ! 118: } ! 119: %{ ! 120: DLOG(log_dsap, LLOG_TRACE, ("Done decode AlgorithmIdentifier (AF)")); ! 121: %} ! 122: ! 123: SubjectPublicKeyInfo [[P struct key_info *]] ! 124: %{ ! 125: struct qbuf *qb; ! 126: int exponent; ! 127: %} ! 128: ::= ! 129: %{ ! 130: DLOG(log_dsap, LLOG_TRACE, ("About to decode SubjectPublicKeyInfo (AF)")); ! 131: %} ! 132: SEQUENCE ! 133: { ! 134: algorithm ! 135: AlgorithmIdentifier [[p &(parm->alg)]], ! 136: subjectPublicKey ! 137: CHOICE { ! 138: BIT STRING [[x parm->value $ parm->n_bits]], ! 139: SEQUENCE { ! 140: [UNIVERSAL 2] IMPLICIT OCTET STRING ! 141: [[q qb]] ! 142: %{ ! 143: parm->value = qb2str(qb); ! 144: parm->n_bits = qb->qb_len*8; ! 145: /* Really should total up pieces ... */ ! 146: qb_free(qb); ! 147: %}, ! 148: INTEGER [[i exponent]] ! 149: } ! 150: } ! 151: } ! 152: %{ ! 153: DLOG(log_dsap, LLOG_TRACE, ("Done decode SubjectPublicKeyInfo (AF)")); ! 154: %} ! 155: ! 156: CertificateToSign [[P struct certificate **]] ! 157: ::= ! 158: %{ ! 159: DLOG(log_dsap, LLOG_TRACE, ("About to decode CertificateToSign (AF)")); ! 160: (*parm)->version = 0; ! 161: %} ! 162: SEQUENCE ! 163: { ! 164: version ! 165: [0] Version [[p &((*parm)->version)]] ! 166: OPTIONAL , ! 167: serialNumber ! 168: CertificateSerialNumber [[p &((*parm)->serial)]], ! 169: signature ! 170: AlgorithmIdentifier [[p &((*parm)->alg)]], ! 171: issuer ! 172: Name [[p &((*parm)->issuer)]] , ! 173: validity ! 174: Validity [[p &((*parm)->valid)]], ! 175: subject ! 176: Name [[p &((*parm)->subject)]] , ! 177: subjectPublicKeyInfo ! 178: SubjectPublicKeyInfo [[p &((*parm)->key)]] ! 179: } ! 180: %{ ! 181: DLOG(log_dsap, LLOG_TRACE, ("Done decode CertificateToSign (AF)")); ! 182: %} ! 183: ! 184: Certificate [[P struct certificate **]] ! 185: ::= ! 186: %{ ! 187: DLOG(log_dsap, LLOG_TRACE, ("About to decode Certificate (AF)")); ! 188: (*parm) = (struct certificate *) calloc(1, sizeof(struct certificate)); ! 189: %} ! 190: SEQUENCE ! 191: { ! 192: CertificateToSign [[p parm]], ! 193: AlgorithmIdentifier [[p &((*parm)->sig.alg)]], ! 194: BIT STRING [[x (*parm)->sig.encrypted $ (*parm)->sig.n_bits]] ! 195: } ! 196: %{ ! 197: DLOG(log_dsap, LLOG_TRACE, ("Done decode Certificate (AF)")); ! 198: %} ! 199: ! 200: CrossCertificates [[P struct certificate_list **]] ! 201: ::= ! 202: SET OF ! 203: %{ ! 204: DLOG(log_dsap, LLOG_TRACE, ("About to decode CrossCertificates (AF)")); ! 205: (*parm) = (struct certificate_list *) ! 206: calloc(1, sizeof(struct certificate_list)); ! 207: (*parm)->reverse = (struct certificate *) 0; ! 208: (*parm)->next = (struct certificate_list *) 0; ! 209: (*parm)->superior = (struct certificate_list *) 0; ! 210: %} ! 211: Certificate [[p &((*parm)->cert)]] ! 212: %{ ! 213: parm = &((*parm)->next); ! 214: DLOG(log_dsap, LLOG_TRACE, ("Done decode CrossCertificates (AF)")); ! 215: %} ! 216: ! 217: ForwardCertificationPath [[P struct certificate_list **]] ! 218: ::= ! 219: SEQUENCE OF ! 220: %{ ! 221: DLOG(log_dsap, LLOG_TRACE, ("About to decode ForwardCertificationPath (AF)")); ! 222: %} ! 223: CrossCertificates [[p parm]] ! 224: %{ ! 225: parm = &((*parm)->superior); ! 226: DLOG(log_dsap, LLOG_TRACE, ("Done decode ForwardCertificationPath (AF)")); ! 227: %} ! 228: ! 229: Certificates [[P struct certificate_list **]] ! 230: ::= ! 231: %{ ! 232: DLOG(log_dsap, LLOG_TRACE, ("About to decode Certificates (AF)")); ! 233: (*parm) = (struct certificate_list *) ! 234: calloc(1, sizeof(struct certificate_list)); ! 235: (*parm)->reverse = (struct certificate *) 0; ! 236: (*parm)->next = (struct certificate_list *) 0; ! 237: (*parm)->superior = (struct certificate_list *) 0; ! 238: %} ! 239: SEQUENCE ! 240: { ! 241: certificate ! 242: Certificate [[p &((*parm)->cert)]], ! 243: certificationPath ! 244: ForwardCertificationPath [[p &((*parm)->superior)]] ! 245: OPTIONAL ! 246: } ! 247: %{ ! 248: DLOG(log_dsap, LLOG_TRACE, ("Done decode Certificates (AF)")); ! 249: %} ! 250: ! 251: CertificatePair [[P struct certificate_list **]] ! 252: ::= ! 253: %{ ! 254: DLOG(log_dsap, LLOG_TRACE, ("About to decode CertificatePair (AF)")); ! 255: (*parm) = (struct certificate_list *) ! 256: calloc(1, sizeof(struct certificate_list)); ! 257: (*parm)->cert = (struct certificate *) 0; ! 258: (*parm)->reverse = (struct certificate *) 0; ! 259: (*parm)->next = (struct certificate_list *) 0; ! 260: (*parm)->superior = (struct certificate_list *) 0; ! 261: %} ! 262: SEQUENCE ! 263: { ! 264: forward ! 265: [0] Certificate [[p &((*parm)->cert)]] ! 266: OPTIONAL , ! 267: reverse ! 268: [1] Certificate [[p &((*parm)->reverse)]] ! 269: OPTIONAL ! 270: } ! 271: %{ ! 272: DLOG(log_dsap, LLOG_TRACE, ("Done decode CertificatePair (AF)")); ! 273: %} ! 274: ! 275: CertificationPath [[P struct certificate_list **]] ! 276: ::= ! 277: %{ ! 278: DLOG(log_dsap, LLOG_TRACE, ("About to decode CertificationPath (AF)")); ! 279: (*parm) = (struct certificate_list *) ! 280: calloc(1, sizeof(struct certificate_list)); ! 281: (*parm)->next = (struct certificate_list *) 0; ! 282: (*parm)->superior = (struct certificate_list *) 0; ! 283: (*parm)->reverse = (struct certificate *) 0; ! 284: %} ! 285: SEQUENCE ! 286: { ! 287: userCertificate ! 288: Certificate [[p &((*parm)->cert)]], ! 289: theCACertificates ! 290: SEQUENCE OF ! 291: CertificatePair [[p &((*parm)->superior)]] ! 292: OPTIONAL ! 293: } ! 294: %{ ! 295: DLOG(log_dsap, LLOG_TRACE, ("Done decode CertificationPath (AF)")); ! 296: %} ! 297: ! 298: RevokedCertificateToSign [[P struct revoked_certificate **]] ! 299: ::= ! 300: %{ ! 301: DLOG(log_dsap, LLOG_TRACE, ("About to decode RevokedCertificateToSign (AF)")); ! 302: (*parm) = (struct revoked_certificate *) ! 303: calloc(1, sizeof(struct revoked_certificate)); ! 304: %} ! 305: SEQUENCE ! 306: { ! 307: signature ! 308: AlgorithmIdentifier [[p &((*parm)->alg)]], ! 309: issuer ! 310: Name [[p &((*parm)->subject)]], ! 311: subject ! 312: CertificateSerialNumber [[p &((*parm)->serial)]], ! 313: revokationDate ! 314: UTCTime [[s (*parm)->revocation_date]] ! 315: } ! 316: %{ ! 317: DLOG(log_dsap, LLOG_TRACE, ("Done decode RevokedCertificateToSign (AF)")); ! 318: %} ! 319: ! 320: RevokedCertificates [[P struct revocation_list **]] ! 321: %{ ! 322: struct revoked_certificate **tmp; ! 323: %} ! 324: ::= ! 325: %{ ! 326: DLOG(log_dsap, LLOG_TRACE, ("About to decode RevokedCertificates (AF)")); ! 327: tmp = (struct revoked_certificate **) &((*parm)->revoked); ! 328: %} ! 329: SEQUENCE ! 330: { ! 331: SEQUENCE OF ! 332: RevokedCertificateToSign [[p tmp]] ! 333: %{ ! 334: tmp = &((*tmp)->next); ! 335: %}, ! 336: AlgorithmIdentifier [[p &((*parm)->sig2.alg)]], ! 337: BIT STRING [[x (*parm)->sig2.encrypted $ (*parm)->sig2.n_bits]] ! 338: } ! 339: %{ ! 340: DLOG(log_dsap, LLOG_TRACE, ("Done decode RevokedCertificates (AF)")); ! 341: %} ! 342: ! 343: CertificateListToSign [[P struct revocation_list **]] ! 344: %{ ! 345: %} ! 346: ::= ! 347: %{ ! 348: DLOG(log_dsap, LLOG_TRACE, ("About to decode CertificateListToSign (AF)")); ! 349: %} ! 350: SEQUENCE ! 351: { ! 352: signature ! 353: AlgorithmIdentifier [[p &((*parm)->alg)]], ! 354: issuer ! 355: Name [[p &((*parm)->issuer)]], ! 356: lastUpdate ! 357: UTCTime [[s (*parm)->last_update]], ! 358: revokedCertificates ! 359: RevokedCertificates [[p parm]] ! 360: OPTIONAL ! 361: } ! 362: %{ ! 363: DLOG(log_dsap, LLOG_TRACE, ("Done decode CertificateListToSign (AF)")); ! 364: %} ! 365: ! 366: CertificateList [[P struct revocation_list **]] ! 367: ::= ! 368: %{ ! 369: DLOG(log_dsap, LLOG_TRACE, ("About to decode CertificateList (AF)")); ! 370: (*parm) = (struct revocation_list *) ! 371: calloc(1, sizeof(struct revocation_list)); ! 372: %} ! 373: SEQUENCE ! 374: { ! 375: CertificateListToSign [[p parm]], ! 376: AlgorithmIdentifier [[p &((*parm)->sig.alg)]], ! 377: BIT STRING [[x (*parm)->sig.encrypted $ (*parm)->sig.n_bits]] ! 378: } ! 379: %{ ! 380: DLOG(log_dsap, LLOG_TRACE, ("Done decode CertificateList (AF)")); ! 381: %} ! 382: ! 383: END
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.