a_bool.c (302408) | a_bool.c (337982) |
---|---|
1/* crypto/asn1/a_bool.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 * --- 49 unchanged lines hidden (view full) --- 58 59#include <stdio.h> 60#include "cryptlib.h" 61#include <openssl/asn1t.h> 62 63int i2d_ASN1_BOOLEAN(int a, unsigned char **pp) 64{ 65 int r; | 1/* crypto/asn1/a_bool.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 * --- 49 unchanged lines hidden (view full) --- 58 59#include <stdio.h> 60#include "cryptlib.h" 61#include <openssl/asn1t.h> 62 63int i2d_ASN1_BOOLEAN(int a, unsigned char **pp) 64{ 65 int r; |
66 unsigned char *p; | 66 unsigned char *p, *allocated = NULL; |
67 68 r = ASN1_object_size(0, 1, V_ASN1_BOOLEAN); 69 if (pp == NULL) 70 return (r); | 67 68 r = ASN1_object_size(0, 1, V_ASN1_BOOLEAN); 69 if (pp == NULL) 70 return (r); |
71 p = *pp; | |
72 | 71 |
72 if (*pp == NULL) { 73 if ((p = allocated = OPENSSL_malloc(r)) == NULL) { 74 ASN1err(ASN1_F_I2D_ASN1_BOOLEAN, ERR_R_MALLOC_FAILURE); 75 return 0; 76 } 77 } else { 78 p = *pp; 79 } 80 |
|
73 ASN1_put_object(&p, 0, 1, V_ASN1_BOOLEAN, V_ASN1_UNIVERSAL); | 81 ASN1_put_object(&p, 0, 1, V_ASN1_BOOLEAN, V_ASN1_UNIVERSAL); |
74 *(p++) = (unsigned char)a; 75 *pp = p; 76 return (r); | 82 *p = (unsigned char)a; 83 84 85 /* 86 * If a new buffer was allocated, just return it back. 87 * If not, return the incremented buffer pointer. 88 */ 89 *pp = allocated != NULL ? allocated : p + 1; 90 return r; |
77} 78 79int d2i_ASN1_BOOLEAN(int *a, const unsigned char **pp, long length) 80{ 81 int ret = -1; 82 const unsigned char *p; 83 long len; 84 int inf, tag, xclass; --- 27 unchanged lines hidden --- | 91} 92 93int d2i_ASN1_BOOLEAN(int *a, const unsigned char **pp, long length) 94{ 95 int ret = -1; 96 const unsigned char *p; 97 long len; 98 int inf, tag, xclass; --- 27 unchanged lines hidden --- |