asn1.c (156067) | asn1.c (216294) |
---|---|
1/* 2 * Copyright (c) 2001-2003 3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus). 4 * All rights reserved. 5 * 6 * Author: Harti Brandt <harti@freebsd.org> 7 * 8 * Redistribution and use in source and binary forms, with or without --- 182 unchanged lines hidden (view full) --- 191 if (b->asn_len < TEMP_LEN) 192 return (ASN_ERR_EOBUF); 193 *ptr = b->asn_ptr; 194 if ((ret = asn_put_header(b, type, ASN_MAXLEN)) == ASN_ERR_OK) 195 assert(b->asn_ptr == *ptr + TEMP_LEN); 196 return (ret); 197} 198enum asn_err | 1/* 2 * Copyright (c) 2001-2003 3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus). 4 * All rights reserved. 5 * 6 * Author: Harti Brandt <harti@freebsd.org> 7 * 8 * Redistribution and use in source and binary forms, with or without --- 182 unchanged lines hidden (view full) --- 191 if (b->asn_len < TEMP_LEN) 192 return (ASN_ERR_EOBUF); 193 *ptr = b->asn_ptr; 194 if ((ret = asn_put_header(b, type, ASN_MAXLEN)) == ASN_ERR_OK) 195 assert(b->asn_ptr == *ptr + TEMP_LEN); 196 return (ret); 197} 198enum asn_err |
199asn_commit_header(struct asn_buf *b, u_char *ptr) | 199asn_commit_header(struct asn_buf *b, u_char *ptr, size_t *moved) |
200{ 201 asn_len_t len; 202 u_int lenlen, shift; 203 204 /* compute length of encoded value without header */ 205 len = b->asn_ptr - (ptr + TEMP_LEN); 206 207 /* insert length. may not fail. */ 208 lenlen = asn_put_len(ptr + 1, len); 209 if (lenlen > TEMP_LEN - 1) 210 return (ASN_ERR_FAILED); 211 212 if (lenlen < TEMP_LEN - 1) { 213 /* shift value down */ 214 shift = (TEMP_LEN - 1) - lenlen; 215 memmove(ptr + 1 + lenlen, ptr + TEMP_LEN, len); 216 b->asn_ptr -= shift; 217 b->asn_len += shift; | 200{ 201 asn_len_t len; 202 u_int lenlen, shift; 203 204 /* compute length of encoded value without header */ 205 len = b->asn_ptr - (ptr + TEMP_LEN); 206 207 /* insert length. may not fail. */ 208 lenlen = asn_put_len(ptr + 1, len); 209 if (lenlen > TEMP_LEN - 1) 210 return (ASN_ERR_FAILED); 211 212 if (lenlen < TEMP_LEN - 1) { 213 /* shift value down */ 214 shift = (TEMP_LEN - 1) - lenlen; 215 memmove(ptr + 1 + lenlen, ptr + TEMP_LEN, len); 216 b->asn_ptr -= shift; 217 b->asn_len += shift; |
218 if (moved != NULL) 219 *moved = shift; |
|
218 } 219 return (ASN_ERR_OK); 220} 221#undef TEMP_LEN 222 223/* 224 * BER integer. This may be used to get a signed 64 bit integer at maximum. 225 * The maximum length should be checked by the caller. This cannot overflow --- 682 unchanged lines hidden (view full) --- 908 if (b->asn_len < len) 909 return (ASN_ERR_EOBUF); 910 b->asn_cptr += len; 911 b->asn_len -= len; 912 return (ASN_ERR_OK); 913} 914 915/* | 220 } 221 return (ASN_ERR_OK); 222} 223#undef TEMP_LEN 224 225/* 226 * BER integer. This may be used to get a signed 64 bit integer at maximum. 227 * The maximum length should be checked by the caller. This cannot overflow --- 682 unchanged lines hidden (view full) --- 910 if (b->asn_len < len) 911 return (ASN_ERR_EOBUF); 912 b->asn_cptr += len; 913 b->asn_len -= len; 914 return (ASN_ERR_OK); 915} 916 917/* |
918 * Add a padding 919 */ 920enum asn_err 921asn_pad(struct asn_buf *b, asn_len_t len) 922{ 923 if (b->asn_len < len) 924 return (ASN_ERR_EOBUF); 925 b->asn_ptr += len; 926 b->asn_len -= len; 927 928 return (ASN_ERR_OK); 929} 930 931/* |
|
916 * Compare two OIDs. 917 * 918 * o1 < o2 : -1 919 * o1 > o2 : +1 920 * o1 = o2 : 0 921 */ 922int 923asn_compare_oid(const struct asn_oid *o1, const struct asn_oid *o2) --- 83 unchanged lines hidden --- | 932 * Compare two OIDs. 933 * 934 * o1 < o2 : -1 935 * o1 > o2 : +1 936 * o1 = o2 : 0 937 */ 938int 939asn_compare_oid(const struct asn_oid *o1, const struct asn_oid *o2) --- 83 unchanged lines hidden --- |