asn1_lib.c (101386) | asn1_lib.c (101613) |
---|---|
1/* crypto/asn1/asn1_lib.c */ 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3 * All rights reserved. 4 * 5 * This package is an SSL implementation written 6 * by Eric Young (eay@cryptsoft.com). 7 * The implementation was written so as to conform with Netscapes SSL. 8 * --- 43 unchanged lines hidden (view full) --- 52 * 53 * The licence and distribution terms for any publically available version or 54 * derivative of this code cannot be changed. i.e. this code cannot simply be 55 * copied and put under another distribution licence 56 * [including the GNU Public Licence.] 57 */ 58 59#include <stdio.h> | 1/* crypto/asn1/asn1_lib.c */ 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3 * All rights reserved. 4 * 5 * This package is an SSL implementation written 6 * by Eric Young (eay@cryptsoft.com). 7 * The implementation was written so as to conform with Netscapes SSL. 8 * --- 43 unchanged lines hidden (view full) --- 52 * 53 * The licence and distribution terms for any publically available version or 54 * derivative of this code cannot be changed. i.e. this code cannot simply be 55 * copied and put under another distribution licence 56 * [including the GNU Public Licence.] 57 */ 58 59#include <stdio.h> |
60#include <limits.h> |
|
60#include "cryptlib.h" 61#include <openssl/asn1.h> 62#include <openssl/asn1_mac.h> 63 64static int asn1_get_length(unsigned char **pp,int *inf,long *rl,int max); 65static void asn1_put_length(unsigned char **pp, int length); 66const char *ASN1_version="ASN.1" OPENSSL_VERSION_PTEXT; 67 --- 68 unchanged lines hidden (view full) --- 136err: 137 ASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_HEADER_TOO_LONG); 138 return(0x80); 139 } 140 141static int asn1_get_length(unsigned char **pp, int *inf, long *rl, int max) 142 { 143 unsigned char *p= *pp; | 61#include "cryptlib.h" 62#include <openssl/asn1.h> 63#include <openssl/asn1_mac.h> 64 65static int asn1_get_length(unsigned char **pp,int *inf,long *rl,int max); 66static void asn1_put_length(unsigned char **pp, int length); 67const char *ASN1_version="ASN.1" OPENSSL_VERSION_PTEXT; 68 --- 68 unchanged lines hidden (view full) --- 137err: 138 ASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_HEADER_TOO_LONG); 139 return(0x80); 140 } 141 142static int asn1_get_length(unsigned char **pp, int *inf, long *rl, int max) 143 { 144 unsigned char *p= *pp; |
144 long ret=0; | 145 unsigned long ret=0; |
145 int i; 146 147 if (max-- < 1) return(0); 148 if (*p == 0x80) 149 { 150 *inf=1; 151 ret=0; 152 p++; --- 12 unchanged lines hidden (view full) --- 165 ret<<=8L; 166 ret|= *(p++); 167 if (max-- == 0) return(0); 168 } 169 } 170 else 171 ret=i; 172 } | 146 int i; 147 148 if (max-- < 1) return(0); 149 if (*p == 0x80) 150 { 151 *inf=1; 152 ret=0; 153 p++; --- 12 unchanged lines hidden (view full) --- 166 ret<<=8L; 167 ret|= *(p++); 168 if (max-- == 0) return(0); 169 } 170 } 171 else 172 ret=i; 173 } |
173 if (ret < 0) | 174 if (ret > LONG_MAX) |
174 return 0; 175 *pp=p; | 175 return 0; 176 *pp=p; |
176 *rl=ret; | 177 *rl=(long)ret; |
177 return(1); 178 } 179 180/* class 0 is constructed 181 * constructed == 2 for indefinite length constructed */ 182void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag, 183 int xclass) 184 { --- 245 unchanged lines hidden --- | 178 return(1); 179 } 180 181/* class 0 is constructed 182 * constructed == 2 for indefinite length constructed */ 183void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag, 184 int xclass) 185 { --- 245 unchanged lines hidden --- |