Annotation of 43BSDReno/contrib/isode-beta/dsap/common/revoke.c, revision 1.1.1.1

1.1       root        1: /* revoke.c - Certificate List attribute syntax */
                      2: 
                      3: /* This syntax is still at the testing stage. Accordingly, quipu should
                      4:  * not load this syntax (just in case).
                      5:  */
                      6: 
                      7: 
                      8: #ifndef        lint
                      9: static char *rcsid = "$Header: /f/osi/dsap/common/RCS/revoke.c,v 7.2 90/01/11 18:35:36 mrose Exp $";
                     10: #endif
                     11: 
                     12: /* 
                     13:  * $Header: /f/osi/dsap/common/RCS/revoke.c,v 7.2 90/01/11 18:35:36 mrose Exp $
                     14:  *
                     15:  *
                     16:  * $Log:       revoke.c,v $
                     17:  * Revision 7.2  90/01/11  18:35:36  mrose
                     18:  * real-sync
                     19:  * 
                     20:  * Revision 7.1  89/12/19  16:19:31  mrose
                     21:  * sync
                     22:  * 
                     23:  * Revision 7.0  89/11/23  21:47:45  mrose
                     24:  * Release 6.0
                     25:  * 
                     26:  */
                     27: 
                     28: /*
                     29:  *                               NOTICE
                     30:  *
                     31:  *    Acquisition, use, and distribution of this module and related
                     32:  *    materials are subject to the restrictions of a license agreement.
                     33:  *    Consult the Preface in the User's Manual for the full terms of
                     34:  *    this agreement.
                     35:  *
                     36:  */
                     37: 
                     38: 
                     39: #include <stdio.h>
                     40: 
                     41: #include "quipu/util.h"
                     42: #include "quipu/entry.h"
                     43: #include "quipu/bind.h"
                     44: 
                     45: PE enc_revoke(parm)
                     46: struct revocation_list *parm;
                     47: {
                     48: PE pe;
                     49:        encode_AF_CertificateList(&pe, 0, 0, NULLCP, parm);
                     50:        return (pe);
                     51: }
                     52: 
                     53: struct revocation_list *dec_revoke(pe)
                     54: PE pe;
                     55: {
                     56: struct revocation_list *result;
                     57: 
                     58:        if (decode_AF_CertificateList(pe, 0, NULLIP, NULLVP, &result) == NOTOK)
                     59:                return (struct revocation_list *) 0;
                     60:        return (result);
                     61: }
                     62: 
                     63: struct revocation_list *str2revoke(str)
                     64: char *str;
                     65: {
                     66: struct revocation_list *result;
                     67: struct revoked_certificate *cert;
                     68: struct revoked_certificate **last;
                     69: OID oid;
                     70: char *ptr;
                     71: 
                     72:        result = (struct revocation_list *) calloc(1, sizeof(*result));
                     73:        if (result == (struct revocation_list *) 0)
                     74:                return (result);
                     75: 
                     76:        ptr = index(str, '#');
                     77:        if (ptr)
                     78:        {
                     79:                *ptr = '\0';
                     80:                ptr++;
                     81:        }
                     82:        else
                     83:                return (struct revocation_list *) 0;
                     84: 
                     85:        oid = name2oid(str);
                     86:        if (oid == NULLOID)
                     87:        {
                     88:                parse_error("Invalid OID %s", str);
                     89:                return (struct revocation_list *) 0;
                     90:        }
                     91:        result->sig.alg.algorithm = oid;
                     92: 
                     93:        str = ptr;
                     94:        ptr = index(str, '#');
                     95:        if (ptr)
                     96:        {
                     97:                *ptr = '\0';
                     98:                ptr++;
                     99:        }
                    100:        else
                    101:                return (struct revocation_list *) 0;
                    102: 
                    103:        str2alg(str, &(result->sig.alg));
                    104: 
                    105:        str=ptr;
                    106:        ptr = index(str, '#');
                    107:        if (ptr)
                    108:        {
                    109:                *ptr = '\0';
                    110:                ptr++;
                    111:        }
                    112: 
                    113:        str2encrypted(str, &(result->sig.encrypted), &(result->sig.n_bits));
                    114: 
                    115:        str=ptr;
                    116:        ptr = index(str, '#');
                    117:        if (ptr)
                    118:        {
                    119:                *ptr = '\0';
                    120:                ptr++;
                    121:        }
                    122: 
                    123:        result->issuer = str2dn(str);
                    124: 
                    125:        str=ptr;
                    126:        ptr = index(str, '#');
                    127:        if (ptr)
                    128:        {
                    129:                *ptr = '\0';
                    130:                ptr++;
                    131:        }
                    132:        else
                    133:                return (struct revocation_list *) 0;
                    134: 
                    135:        oid = name2oid(str);
                    136:        if (oid == NULLOID)
                    137:        {
                    138:                parse_error("Invalid OID %s", str);
                    139:                return (struct revocation_list *) 0;
                    140:        }
                    141:        result->alg.algorithm = oid;
                    142: 
                    143:        str=ptr;
                    144:        ptr = index(str, '#');
                    145:        if (ptr)
                    146:        {
                    147:                *ptr = '\0';
                    148:                ptr++;
                    149:        }
                    150:        else return (struct revocation_list *) 0;
                    151: 
                    152:        str2alg(str, &(result->alg));
                    153: 
                    154:        str=ptr;
                    155:        ptr = index(str, '#');
                    156:        if (ptr)
                    157:        {
                    158:                *ptr = '\0';
                    159:                ptr++;
                    160:        }
                    161:        /* This may be the end of the string */
                    162: 
                    163:        result->last_update = strdup(str);
                    164: 
                    165:        if ((str = ptr) == NULLCP)
                    166:                return (result);
                    167:        ptr = index(str, '#');
                    168:        if (ptr == NULLCP)
                    169:                return(result);
                    170: 
                    171:        *ptr = '\0';
                    172:        ptr++;
                    173: 
                    174:        oid = name2oid(str);
                    175:        result->sig2.alg.algorithm = oid;
                    176: 
                    177:        str=ptr;
                    178:        ptr = index(str, '#');
                    179:        if (ptr)
                    180:        {
                    181:                *ptr = '\0';
                    182:                ptr++;
                    183:        }
                    184:        else
                    185:                return (struct revocation_list *) 0;
                    186: 
                    187:        str2alg(str, &(result->sig2.alg));
                    188: 
                    189:        str=ptr;
                    190:        ptr = index(str, '#');
                    191:        if (ptr)
                    192:        {
                    193:                *ptr = '\0';
                    194:                ptr++;
                    195:        }
                    196:        /* This may be the end of the string */
                    197: 
                    198:        str2encrypted(str, &(result->sig2.encrypted), &(result->sig2.n_bits));
                    199: 
                    200:        last = (struct revoked_certificate **) &(result->revoked);
                    201: 
                    202:        while (str = ptr, ((ptr = index(str, '#')) != NULLCP))
                    203:        {
                    204:                *ptr = '\0';
                    205:                ptr++;
                    206: 
                    207:                cert = (struct revoked_certificate *) calloc(1, sizeof(*cert));
                    208:                if (cert == (struct revoked_certificate *) 0)
                    209:                        return ((struct revocation_list *) 0);
                    210: 
                    211:                *last =  cert;
                    212:                last = &(cert->next);
                    213:                cert->next = (struct revoked_certificate *) 0;
                    214: 
                    215:                cert->subject = str2dn(str);
                    216:                if (cert->subject == NULLDN)
                    217:                {
                    218:                        parse_error("Invalid DN %s", str);
                    219:                        return ((struct revocation_list *) 0);
                    220:                }
                    221: 
                    222:                str=ptr;
                    223:                ptr = index(str, '#');
                    224:                if (ptr)
                    225:                {
                    226:                        *ptr = '\0';
                    227:                        ptr++;
                    228:                }
                    229:                else
                    230:                        return (struct revocation_list *) 0;
                    231: 
                    232:                oid = name2oid(str);
                    233:                if (oid == NULLOID)
                    234:                {
                    235:                        parse_error("Invalid OID %s", str);
                    236:                        return (struct revocation_list *) 0;
                    237:                }
                    238: 
                    239:                cert->alg.algorithm = oid;
                    240: 
                    241:                str=ptr;
                    242:                ptr = index(str, '#');
                    243:                if (ptr)
                    244:                {
                    245:                        *ptr = '\0';
                    246:                        ptr++;
                    247:                }
                    248:                else
                    249:                        return (struct revocation_list *) 0;
                    250: 
                    251:                str2alg(str, &(cert->alg));
                    252: 
                    253:                str=ptr;
                    254:                ptr = index(str, '#');
                    255:                if (ptr)
                    256:                {
                    257:                        *ptr = '\0';
                    258:                        ptr++;
                    259:                }
                    260:                else
                    261:                        return (struct revocation_list *) 0;
                    262: 
                    263:                cert->serial = atoi(str);
                    264: 
                    265:                str=ptr;
                    266:                ptr = index(str, '#');
                    267:                if (ptr)
                    268:                {
                    269:                        *ptr = '\0';
                    270:                        ptr++;
                    271:                }
                    272:                /* may be the end of the string */
                    273: 
                    274:                cert->revocation_date = strdup(str);
                    275: 
                    276:        }
                    277: 
                    278:        return (result);
                    279: }
                    280: 
                    281: print_revoked(ps, parm, format)
                    282: PS ps;
                    283: struct revoked_certificate *parm;
                    284: int format;
                    285: {
                    286: struct revoked_certificate *tmp;
                    287: 
                    288:        tmp = parm;
                    289:        while (tmp)
                    290:        {
                    291:                dn_print(ps, tmp->subject, EDBOUT);
                    292:                ps_printf(ps, "#");
                    293:                print_algid(ps, &(tmp->alg), format);
                    294:                ps_printf(ps, "%d#", tmp->serial);
                    295:                ps_printf(ps, "%s#", tmp->revocation_date);
                    296:                tmp = tmp->next;
                    297:        }
                    298: }
                    299: 
                    300: print_revoke(ps, parm, format)
                    301: PS ps;
                    302: struct revocation_list *parm;
                    303: int format;
                    304: {
                    305:        print_algid(ps, &(parm->sig.alg), format);
                    306:        print_encrypted(ps, parm->sig.encrypted, parm->sig.n_bits, format);
                    307: 
                    308:        dn_print(ps, parm->issuer, EDBOUT);
                    309:        ps_printf(ps, "#");
                    310:        print_algid(ps, &(parm->alg), format);
                    311:        utcprint(ps, parm->last_update, format);
                    312:        ps_printf(ps, "#");
                    313:        if (parm->revoked)
                    314:        {
                    315:                print_algid(ps, &(parm->sig2.alg), format);
                    316:                print_encrypted(ps, parm->sig2.encrypted, 
                    317:                        parm->sig2.n_bits, format);  
                    318:                print_revoked(ps, parm->revoked, format);
                    319:        }
                    320:        
                    321: }
                    322: 
                    323: struct revocation_list *revoke_cpy(parm)
                    324: struct revocation_list *parm;
                    325: {
                    326:        return (parm);
                    327: }
                    328: 
                    329: revoke_cmp(a, b)
                    330: struct revocation_list *a, *b;
                    331: {
                    332: int ret;
                    333: 
                    334:        ret = dn_cmp(a->issuer, b->issuer);
                    335:        if (ret != 0)
                    336:                return (ret);
                    337:        ret = strcmp(a->last_update, b->last_update);
                    338:        if (ret != 0)
                    339:                return (ret);
                    340: 
                    341:        return (0);
                    342: }
                    343: 
                    344: /* ARGSUSED */
                    345: 
                    346: revoke_free(parm)
                    347: struct signature *parm;
                    348: {
                    349: }
                    350: 
                    351: revoke_syntax()
                    352: {
                    353:        (void) add_attribute_syntax(
                    354:                "CertificateList",
                    355:                (IFP)enc_revoke,        (IFP)dec_revoke,
                    356:                (IFP)str2revoke,        print_revoke,
                    357:                (IFP)revoke_cpy,        revoke_cmp,
                    358:                revoke_free,    NULLCP,
                    359:                NULLIFP,        TRUE);
                    360: }

unix.superglobalmegacorp.com

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