-: 0:Source:asn1_get.c -: 0:Graph:/var/tsitkova/Sources/v10/trunk/src/lib/krb5/asn.1/asn1_get.so.gcno -: 0:Data:/var/tsitkova/Sources/v10/trunk/src/lib/krb5/asn.1/asn1_get.so.gcda -: 0:Runs:1603 -: 0:Programs:1 -: 1:/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -: 2:/* lib/krb5/asn.1/asn1_get.c */ -: 3:/* -: 4: * Copyright 1994 by the Massachusetts Institute of Technology. -: 5: * All Rights Reserved. -: 6: * -: 7: * Export of this software from the United States of America may -: 8: * require a specific license from the United States Government. -: 9: * It is the responsibility of any person or organization contemplating -: 10: * export to obtain such a license before exporting. -: 11: * -: 12: * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and -: 13: * distribute this software and its documentation for any purpose and -: 14: * without fee is hereby granted, provided that the above copyright -: 15: * notice appear in all copies and that both that copyright notice and -: 16: * this permission notice appear in supporting documentation, and that -: 17: * the name of M.I.T. not be used in advertising or publicity pertaining -: 18: * to distribution of the software without specific, written prior -: 19: * permission. Furthermore if you modify this software you must label -: 20: * your software as modified software and not distribute it in such a -: 21: * fashion that it might be confused with the original M.I.T. software. -: 22: * M.I.T. makes no representations about the suitability of -: 23: * this software for any purpose. It is provided "as is" without express -: 24: * or implied warranty. -: 25: */ -: 26: -: 27:#include "asn1_get.h" -: 28: -: 29:asn1_error_code 513344: 30:asn1_get_tag_2(asn1buf *buf, taginfo *t) -: 31:{ -: 32: asn1_error_code retval; -: 33: 1026688: 34: if (buf == NULL || buf->base == NULL || 513344: 35: buf->bound - buf->next + 1 <= 0) { 73812: 36: t->tagnum = ASN1_TAGNUM_CEILING; /* emphatically not an EOC tag */ 73812: 37: t->asn1class = UNIVERSAL; 73812: 38: t->construction = PRIMITIVE; 73812: 39: t->length = 0; 73812: 40: t->indef = 0; 73812: 41: return 0; -: 42: } -: 43: { -: 44: /* asn1_get_id(buf, t) */ 439532: 45: asn1_tagnum tn=0; -: 46: asn1_octet o; -: 47: -: 48:#define ASN1_CLASS_MASK 0xC0 -: 49:#define ASN1_CONSTRUCTION_MASK 0x20 -: 50:#define ASN1_TAG_NUMBER_MASK 0x1F -: 51: 439532: 52: retval = asn1buf_remove_octet(buf,&o); 439532: 53: if (retval) #####: 54: return retval; -: 55: 439532: 56: t->asn1class = (asn1_class)(o&ASN1_CLASS_MASK); 439532: 57: t->construction = (asn1_construction)(o&ASN1_CONSTRUCTION_MASK); 439532: 58: if ((o&ASN1_TAG_NUMBER_MASK) != ASN1_TAG_NUMBER_MASK) { -: 59: /* low-tag-number form */ 439287: 60: t->tagnum = (asn1_tagnum)(o&ASN1_TAG_NUMBER_MASK); -: 61: } else { -: 62: /* high-tag-number form */ -: 63: do { 252: 64: retval = asn1buf_remove_octet(buf,&o); 252: 65: if (retval) return retval; 252: 66: tn = (tn<<7) + (asn1_tagnum)(o&0x7F); 252: 67: } while (o&0x80); 245: 68: t->tagnum = tn; -: 69: } -: 70: } -: 71: -: 72: { -: 73: /* asn1_get_length(buf, t) */ -: 74: asn1_octet o; -: 75: 439532: 76: t->indef = 0; 439532: 77: retval = asn1buf_remove_octet(buf,&o); 439532: 78: if (retval) return retval; 439530: 79: if ((o&0x80) == 0) { 403173: 80: t->length = (int)(o&0x7F); -: 81: } else { -: 82: int num; 36357: 83: int len=0; -: 84: 167676: 85: for (num = (int)(o&0x7F); num>0; num--) { 132810: 86: retval = asn1buf_remove_octet(buf,&o); 132810: 87: if (retval) return retval; 131319: 88: len = (len<<8) + (int)o; -: 89: } 34866: 90: if (len < 0) 35: 91: return ASN1_OVERRUN; 34831: 92: if (!len) 47: 93: t->indef = 1; 34831: 94: t->length = len; -: 95: } -: 96: } 438004: 97: if (t->indef && t->construction != CONSTRUCTED) #####: 98: return ASN1_MISMATCH_INDEF; 438004: 99: return 0; -: 100:} -: 101: -: 102:asn1_error_code 84460: 103:asn1_get_sequence(asn1buf *buf, unsigned int *retlen, int *indef) -: 104:{ -: 105: taginfo t; -: 106: asn1_error_code retval; -: 107: 84460: 108: retval = asn1_get_tag_2(buf, &t); 84460: 109: if (retval) 246: 110: return retval; 167854: 111: if (t.asn1class != UNIVERSAL || t.construction != CONSTRUCTED || 83640: 112: t.tagnum != ASN1_SEQUENCE) 589: 113: return ASN1_BAD_ID; 83625: 114: if (retlen) 83625: 115: *retlen = t.length; 83625: 116: if (indef) 83625: 117: *indef = t.indef; 83625: 118: return 0; -: 119:}