Annotation of 43BSDReno/contrib/isode-beta/dsap/x500as/af-enc.py, revision 1.1.1.1

1.1       root        1: -- af-enc.py - manually-augmented AuthenticationFramework module
                      2: 
                      3: -- $Header: /f/osi/dsap/x500as/RCS/af-enc.py,v 7.0 89/11/23 21:50:03 mrose Rel $
                      4: --
                      5: --
                      6: -- $Log:       af-enc.py,v $
                      7: -- Revision 7.0  89/11/23  21:50:03  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 encode_UNIV_UTCTime build_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: ENCODER encode
                     64: 
                     65: Version [[P int *]]
                     66:        ::=
                     67:         %{
                     68:         DLOG(log_dsap, LLOG_TRACE, ("About to encode Version (AF)"));
                     69:         %}
                     70:        INTEGER [[i *parm]]
                     71:         %{
                     72:         DLOG(log_dsap, LLOG_TRACE, ("Done encode Version (AF)"));
                     73:         %}
                     74: 
                     75: CertificateSerialNumber [[P int *]]
                     76:        ::=
                     77:         %{
                     78:         DLOG(log_dsap, LLOG_TRACE, ("About to encode CertificateSerialNumber (AF)"));
                     79:         %}
                     80:        INTEGER [[i *parm]]
                     81:         %{
                     82:         DLOG(log_dsap, LLOG_TRACE, ("Done encode CertificateSerialNumber (AF)"));
                     83:         %}
                     84: 
                     85: Validity [[P struct validity *]]
                     86:        ::=
                     87:         %{
                     88:         DLOG(log_dsap, LLOG_TRACE, ("About to encode 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 encode Validity (AF)"));
                     99:         %}
                    100: 
                    101: AlgorithmIdentifier [[P struct alg_id *]]
                    102:        ::=
                    103:         %{
                    104:         DLOG(log_dsap, LLOG_TRACE, ("About to encode AlgorithmIdentifier (AF)"));
                    105:        if (parm->p_type == ALG_PARM_ABSENT)
                    106:                parm->asn = NULLPE;
                    107:        else if (parm->asn == NULLPE)
                    108:                if (parm -> p_type = ALG_PARM_NUMERIC)
                    109:                        parm->asn = int2prim(parm->un.numeric);
                    110: 
                    111:         %}
                    112:        SEQUENCE
                    113:        {
                    114:        algorithm
                    115:                OBJECT IDENTIFIER [[O parm->algorithm]],
                    116:        parameters
                    117:                ANY [[a parm->asn]]
                    118:                    OPTIONAL <<parm->asn>>
                    119:        }
                    120:         %{
                    121:         DLOG(log_dsap, LLOG_TRACE, ("Done encode AlgorithmIdentifier (AF)"));
                    122:         %}
                    123: 
                    124: SubjectPublicKeyInfo [[P struct key_info *]]
                    125:        ::=
                    126:         %{
                    127:         DLOG(log_dsap, LLOG_TRACE, ("About to encode SubjectPublicKeyInfo (AF)"));
                    128:         %}
                    129:        SEQUENCE
                    130:        {
                    131:        algorithm
                    132:                AlgorithmIdentifier [[p &(parm->alg)]],
                    133:        subjectPublicKey
                    134:                BIT STRING [[x parm->value $ parm->n_bits]]
                    135:        }
                    136:         %{
                    137:         DLOG(log_dsap, LLOG_TRACE, ("Done encode SubjectPublicKeyInfo (AF)"));
                    138:         %}
                    139: 
                    140: CertificateToSign [[P struct certificate *]]
                    141:        ::=
                    142:         %{
                    143:         DLOG(log_dsap, LLOG_TRACE, ("About to encode CertificateToSign (AF)"));
                    144:         %}
                    145:        SEQUENCE
                    146:        {
                    147:        version
                    148:                [0] Version [[p &(parm->version)]]
                    149:                    -- DEFAULT v1988 ,
                    150:                    OPTIONAL <<parm -> version>>,
                    151:        serialNumber
                    152:                CertificateSerialNumber [[p &(parm->serial)]] ,
                    153:        signature
                    154:                AlgorithmIdentifier [[p &(parm -> alg)]],
                    155:        issuer
                    156:                Name [[p parm->issuer]] ,
                    157:        validity
                    158:                Validity [[p &(parm->valid)]],
                    159:        subject
                    160:                Name [[p parm->subject]] ,
                    161:        subjectPublicKeyInfo
                    162:                SubjectPublicKeyInfo [[p &(parm -> key)]]
                    163:        }
                    164:         %{
                    165:         DLOG(log_dsap, LLOG_TRACE, ("Done encode CertificateToSign (AF)"));
                    166:         %}
                    167: 
                    168: Certificate [[P struct certificate *]]
                    169:        ::=
                    170:         %{
                    171:         DLOG(log_dsap, LLOG_TRACE, ("About to encode Certificate (AF)"));
                    172:         %}
                    173:        SEQUENCE
                    174:        {
                    175:                CertificateToSign [[p parm]],
                    176:                AlgorithmIdentifier [[p &(parm->sig.alg)]],
                    177:                BIT STRING [[x parm->sig.encrypted $ parm->sig.n_bits]]
                    178:        }
                    179:         %{
                    180:         DLOG(log_dsap, LLOG_TRACE, ("Done encode Certificate (AF)"));
                    181:         %}
                    182: 
                    183: CrossCertificates [[P struct certificate_list *]]
                    184: %{
                    185: struct certificate_list *tmp;
                    186: %}
                    187:        ::=
                    188:         %{
                    189:         DLOG(log_dsap, LLOG_TRACE, ("About to encode CrossCertificates (AF)"));
                    190:         %}
                    191:        SET OF
                    192:        <<tmp=parm;tmp;tmp=tmp->next>>
                    193:                Certificate [[p tmp->cert]]
                    194:         %{
                    195:         DLOG(log_dsap, LLOG_TRACE, ("Done encode CrossCertificates (AF)"));
                    196:         %}
                    197: 
                    198: ForwardCertificationPath [[P struct certificate_list *]]
                    199: %{
                    200: struct certificate_list *tmp;
                    201: %}
                    202:        ::=
                    203:         %{
                    204:         DLOG(log_dsap, LLOG_TRACE, ("About to encode ForwardCertificationPath (AF)"));
                    205:         %}
                    206:        SEQUENCE OF
                    207:        <<tmp=parm;tmp;tmp=tmp->superior>>
                    208:                CrossCertificates [[p tmp]]
                    209:         %{
                    210:         DLOG(log_dsap, LLOG_TRACE, ("Done encode ForwardCertificationPath (AF)"));
                    211:         %}
                    212: 
                    213: Certificates [[P struct certificate_list *]]
                    214:        ::=
                    215:         %{
                    216:         DLOG(log_dsap, LLOG_TRACE, ("About to encode Certificates (AF)"));
                    217:         %}
                    218:        SEQUENCE
                    219:        {
                    220:        certificate 
                    221:                Certificate [[p parm->cert]],
                    222:        certificationPath
                    223:                ForwardCertificationPath [[p parm->superior]]
                    224:                    OPTIONAL <<parm->superior>>
                    225:        }
                    226:         %{
                    227:         DLOG(log_dsap, LLOG_TRACE, ("Done encode Certificates (AF)"));
                    228:         %}
                    229: 
                    230: CertificatePair [[P struct certificate_list *]]
                    231:        ::=
                    232:         %{
                    233:         DLOG(log_dsap, LLOG_TRACE, ("About to encode CertificatePair (AF)"));
                    234:         %}
                    235:        SEQUENCE
                    236:        {
                    237:        forward
                    238:                [0] Certificate [[p parm->cert]]
                    239:                    OPTIONAL <<parm->cert>>,
                    240:        reverse
                    241:                [1] Certificate [[p parm->reverse]]
                    242:                    OPTIONAL <<parm->reverse>>
                    243:        }
                    244:         %{
                    245:         DLOG(log_dsap, LLOG_TRACE, ("Done encode CertificatePair (AF)"));
                    246:         %}
                    247: 
                    248: CertificationPath [[P struct certificate_list *]]
                    249: %{
                    250: struct certificate_list *tmp;
                    251: %}
                    252:        ::=
                    253:         %{
                    254:         DLOG(log_dsap, LLOG_TRACE, ("Abou to encode CertificationPath (AF)"));
                    255:         %}
                    256:        SEQUENCE
                    257:        {
                    258:        userCertificate
                    259:                Certificate [[p parm->cert]],
                    260:        theCACertificates
                    261:                SEQUENCE OF
                    262:                <<tmp = parm->superior; tmp; tmp = tmp->superior>>
                    263:                        CertificatePair [[p tmp]]
                    264:                    OPTIONAL <<parm->superior>>
                    265:        }
                    266:         %{
                    267:         DLOG(log_dsap, LLOG_TRACE, ("Done encode CertificationPath (AF)"));
                    268:         %}
                    269: 
                    270: RevokedCertificateToSign [[P struct revoked_certificate *]]
                    271:        ::=
                    272:        %{
                    273:        DLOG(log_dsap, LLOG_TRACE, ("About to encode RevokedCertificateToSign (AF)"));
                    274:        %}
                    275:        SEQUENCE
                    276:        {
                    277:        signature
                    278:                AlgorithmIdentifier [[p &(parm->alg)]],
                    279:        issuer
                    280:                Name [[p parm->subject]] ,
                    281:        subject
                    282:                CertificateSerialNumber [[p &(parm->serial)]],
                    283:        revokationDate
                    284:                UTCTime [[s parm->revocation_date]]
                    285:        } 
                    286:        %{
                    287:        DLOG(log_dsap, LLOG_TRACE, ("Done encode RevokedCertificateToSign (AF)"));
                    288:        %}
                    289: 
                    290: RevokedCertificates [[P struct revocation_list *]]
                    291: %{
                    292: struct revoked_certificate *tmp;
                    293: %}
                    294:        ::=
                    295:        %{
                    296:        DLOG(log_dsap, LLOG_TRACE, ("About to encode RevokedCertificates (AF)"));
                    297:        %}
                    298:        SEQUENCE
                    299:        {
                    300:        SEQUENCE OF <<tmp = parm->revoked; tmp; tmp=tmp->next>>
                    301:                RevokedCertificateToSign [[p tmp]],
                    302:        AlgorithmIdentifier [[p &(parm->sig2.alg)]],
                    303:        BIT STRING [[x parm->sig2.encrypted $ parm->sig2.n_bits]]
                    304:        }
                    305:        %{
                    306:        DLOG(log_dsap, LLOG_TRACE, ("Done encode RevokedCertificates (AF)"));
                    307:        %}
                    308:        
                    309: CertificateListToSign [[P struct revocation_list *]]
                    310:        ::=
                    311:         %{
                    312:         DLOG(log_dsap, LLOG_TRACE, ("About to encode CertificateListToSign (AF)"));
                    313:         %}
                    314:        SEQUENCE
                    315:        {
                    316:        signature
                    317:                AlgorithmIdentifier [[p &(parm->alg)]],
                    318:        issuer
                    319:                Name [[p parm->issuer]] ,
                    320:        lastUpdate
                    321:                UTCTime [[s parm->last_update]],
                    322:        revokedCertificates
                    323:                RevokedCertificates [[p parm]]
                    324:                    OPTIONAL <<parm->revoked>>
                    325:        }
                    326:         %{
                    327:         DLOG(log_dsap, LLOG_TRACE, ("Done encode CertificateListToSign (AF)"));
                    328:         %}
                    329: 
                    330: CertificateList [[P struct revocation_list *]]
                    331:        ::=
                    332:         %{
                    333:         DLOG(log_dsap, LLOG_TRACE, ("About to encode CertificateList (AF)"));
                    334:         %}
                    335:        SEQUENCE
                    336:        {
                    337:                CertificateListToSign [[p parm]],
                    338:                AlgorithmIdentifier [[p &(parm->sig.alg)]],
                    339:                BIT STRING [[x parm->sig.encrypted $ parm->sig.n_bits]]
                    340:        }
                    341:         %{
                    342:         DLOG(log_dsap, LLOG_TRACE, ("Done encode CertificateList (AF)"));
                    343:         %}
                    344: 
                    345: END

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.