diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/evp_asn1.c')
-rw-r--r-- | src/lib/libcrypto/asn1/evp_asn1.c | 62 |
1 files changed, 27 insertions, 35 deletions
diff --git a/src/lib/libcrypto/asn1/evp_asn1.c b/src/lib/libcrypto/asn1/evp_asn1.c index ebe34a3362..3506005a71 100644 --- a/src/lib/libcrypto/asn1/evp_asn1.c +++ b/src/lib/libcrypto/asn1/evp_asn1.c | |||
@@ -58,26 +58,22 @@ | |||
58 | 58 | ||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
61 | #include "asn1.h" | 61 | #include <openssl/asn1.h> |
62 | #include "asn1_mac.h" | 62 | #include <openssl/asn1_mac.h> |
63 | 63 | ||
64 | int ASN1_TYPE_set_octetstring(a,data,len) | 64 | int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len) |
65 | ASN1_TYPE *a; | ||
66 | unsigned char *data; | ||
67 | int len; | ||
68 | { | 65 | { |
69 | ASN1_STRING *os; | 66 | ASN1_STRING *os; |
70 | 67 | ||
71 | if ((os=ASN1_OCTET_STRING_new()) == NULL) return(0); | 68 | if ((os=M_ASN1_OCTET_STRING_new()) == NULL) return(0); |
72 | if (!ASN1_OCTET_STRING_set(os,data,len)) return(0); | 69 | if (!M_ASN1_OCTET_STRING_set(os,data,len)) return(0); |
73 | ASN1_TYPE_set(a,V_ASN1_OCTET_STRING,(char *)os); | 70 | ASN1_TYPE_set(a,V_ASN1_OCTET_STRING,os); |
74 | return(1); | 71 | return(1); |
75 | } | 72 | } |
76 | 73 | ||
77 | int ASN1_TYPE_get_octetstring(a,data,max_len) | 74 | /* int max_len: for returned value */ |
78 | ASN1_TYPE *a; | 75 | int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data, |
79 | unsigned char *data; | 76 | int max_len) |
80 | int max_len; /* for returned value */ | ||
81 | { | 77 | { |
82 | int ret,num; | 78 | int ret,num; |
83 | unsigned char *p; | 79 | unsigned char *p; |
@@ -87,8 +83,8 @@ int max_len; /* for returned value */ | |||
87 | ASN1err(ASN1_F_ASN1_TYPE_GET_OCTETSTRING,ASN1_R_DATA_IS_WRONG); | 83 | ASN1err(ASN1_F_ASN1_TYPE_GET_OCTETSTRING,ASN1_R_DATA_IS_WRONG); |
88 | return(-1); | 84 | return(-1); |
89 | } | 85 | } |
90 | p=ASN1_STRING_data(a->value.octet_string); | 86 | p=M_ASN1_STRING_data(a->value.octet_string); |
91 | ret=ASN1_STRING_length(a->value.octet_string); | 87 | ret=M_ASN1_STRING_length(a->value.octet_string); |
92 | if (ret < max_len) | 88 | if (ret < max_len) |
93 | num=ret; | 89 | num=ret; |
94 | else | 90 | else |
@@ -97,11 +93,8 @@ int max_len; /* for returned value */ | |||
97 | return(ret); | 93 | return(ret); |
98 | } | 94 | } |
99 | 95 | ||
100 | int ASN1_TYPE_set_int_octetstring(a,num,data,len) | 96 | int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, unsigned char *data, |
101 | ASN1_TYPE *a; | 97 | int len) |
102 | long num; | ||
103 | unsigned char *data; | ||
104 | int len; | ||
105 | { | 98 | { |
106 | int n,size; | 99 | int n,size; |
107 | ASN1_OCTET_STRING os,*osp; | 100 | ASN1_OCTET_STRING os,*osp; |
@@ -124,23 +117,22 @@ int len; | |||
124 | /* Grow the 'string' */ | 117 | /* Grow the 'string' */ |
125 | ASN1_STRING_set(osp,NULL,size); | 118 | ASN1_STRING_set(osp,NULL,size); |
126 | 119 | ||
127 | ASN1_STRING_length(osp)=size; | 120 | M_ASN1_STRING_length_set(osp, size); |
128 | p=ASN1_STRING_data(osp); | 121 | p=M_ASN1_STRING_data(osp); |
129 | 122 | ||
130 | ASN1_put_object(&p,1,n,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); | 123 | ASN1_put_object(&p,1,n,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); |
131 | i2d_ASN1_INTEGER(&in,&p); | 124 | i2d_ASN1_INTEGER(&in,&p); |
132 | M_i2d_ASN1_OCTET_STRING(&os,&p); | 125 | M_i2d_ASN1_OCTET_STRING(&os,&p); |
133 | 126 | ||
134 | ASN1_TYPE_set(a,V_ASN1_SEQUENCE,(char *)osp); | 127 | ASN1_TYPE_set(a,V_ASN1_SEQUENCE,osp); |
135 | return(1); | 128 | return(1); |
136 | } | 129 | } |
137 | 130 | ||
138 | /* we return the actual length... */ | 131 | /* we return the actual length..., num may be missing, in which |
139 | int ASN1_TYPE_get_int_octetstring(a,num,data,max_len) | 132 | * case, set it to zero */ |
140 | ASN1_TYPE *a; | 133 | /* int max_len: for returned value */ |
141 | long *num; | 134 | int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, unsigned char *data, |
142 | unsigned char *data; | 135 | int max_len) |
143 | int max_len; /* for returned value */ | ||
144 | { | 136 | { |
145 | int ret= -1,n; | 137 | int ret= -1,n; |
146 | ASN1_INTEGER *ai=NULL; | 138 | ASN1_INTEGER *ai=NULL; |
@@ -153,8 +145,8 @@ int max_len; /* for returned value */ | |||
153 | { | 145 | { |
154 | goto err; | 146 | goto err; |
155 | } | 147 | } |
156 | p=ASN1_STRING_data(a->value.sequence); | 148 | p=M_ASN1_STRING_data(a->value.sequence); |
157 | length=ASN1_STRING_length(a->value.sequence); | 149 | length=M_ASN1_STRING_length(a->value.sequence); |
158 | 150 | ||
159 | c.pp= &p; | 151 | c.pp= &p; |
160 | c.p=p; | 152 | c.p=p; |
@@ -173,21 +165,21 @@ int max_len; /* for returned value */ | |||
173 | if (num != NULL) | 165 | if (num != NULL) |
174 | *num=ASN1_INTEGER_get(ai); | 166 | *num=ASN1_INTEGER_get(ai); |
175 | 167 | ||
176 | ret=ASN1_STRING_length(os); | 168 | ret=M_ASN1_STRING_length(os); |
177 | if (max_len > ret) | 169 | if (max_len > ret) |
178 | n=ret; | 170 | n=ret; |
179 | else | 171 | else |
180 | n=max_len; | 172 | n=max_len; |
181 | 173 | ||
182 | if (data != NULL) | 174 | if (data != NULL) |
183 | memcpy(data,ASN1_STRING_data(os),n); | 175 | memcpy(data,M_ASN1_STRING_data(os),n); |
184 | if (0) | 176 | if (0) |
185 | { | 177 | { |
186 | err: | 178 | err: |
187 | ASN1err(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,ASN1_R_DATA_IS_WRONG); | 179 | ASN1err(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,ASN1_R_DATA_IS_WRONG); |
188 | } | 180 | } |
189 | if (os != NULL) ASN1_OCTET_STRING_free(os); | 181 | if (os != NULL) M_ASN1_OCTET_STRING_free(os); |
190 | if (ai != NULL) ASN1_INTEGER_free(ai); | 182 | if (ai != NULL) M_ASN1_INTEGER_free(ai); |
191 | return(ret); | 183 | return(ret); |
192 | } | 184 | } |
193 | 185 | ||