1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
|
Fix a lot of warnings and (what seems to be) two errors...
-mi
--- ias.h 2006-03-13 06:45:20.000000000 -0500
+++ ias.h 2008-04-29 10:03:02.000000000 -0400
@@ -6,13 +6,6 @@
*/
-/* Macros */
-
-#define i2d_pkcs7_issuer_and_subject_bio(bp, ias) \
- ASN1_i2d_bio(i2d_pkcs7_issuer_and_subject, bp, (unsigned char *)ias)
-#define i2d_PKCS7_ISSUER_AND_SERIAL_bio(bp, ias) \
- ASN1_i2d_bio(i2d_PKCS7_ISSUER_AND_SERIAL, bp, (unsigned char *)ias)
-
/* Routines */
-int i2d_pkcs7_issuer_and_subject(pkcs7_issuer_and_subject *, unsigned char **);
+int i2d_pkcs7_issuer_and_subject(void *, unsigned char **);
pkcs7_issuer_and_subject *
d2i_pkcs7_issuer_and_subject(pkcs7_issuer_and_subject **, unsigned char **,
--- net.c 2007-12-27 01:08:39.000000000 -0500
+++ net.c 2008-04-29 10:03:02.000000000 -0400
@@ -151,13 +151,13 @@
/* URL-encode the input and return back encoded string */
-char * url_encode(char *s, size_t n) {
+char * url_encode(const char *s, size_t n) {
char *r;
size_t len;
- int i;
+ size_t i;
char ch[2];
/* Allocate 2 times bigger space than the original string */
len = 2 * n;
- r = (char *)malloc(len);
+ r = malloc(len);
if (r == NULL) {
return NULL;
--- pkcs7.c 2006-03-13 06:45:21.000000000 -0500
+++ pkcs7.c 2008-04-29 10:03:02.000000000 -0400
@@ -10,4 +10,18 @@
#include "ias.h"
+static int
+pkcs7_translator(void *p, unsigned char **out)
+{
+ return i2d_PKCS7_ISSUER_AND_SERIAL(p, out);
+}
+#define i2d_pkcs7_issuer_and_subject_bio(bp, ias) \
+ ASN1_i2d_bio(i2d_pkcs7_issuer_and_subject, bp, (unsigned char *)ias)
+#define i2d_PKCS7_ISSUER_AND_SERIAL_bio(bp, ias) \
+ ASN1_i2d_bio(pkcs7_translator, bp, (unsigned char *)ias)
+
+static int add_attribute_string(STACK_OF(X509_ATTRIBUTE) *, int,
+ const char *);
+static int add_attribute_octet(STACK_OF(X509_ATTRIBUTE) *, int,
+ const char *, int);
/*
* Wrap data in PKCS#7 envelopes and base64-encode the result.
@@ -64,5 +78,5 @@
exit (SCEP_PKISTATUS_P7);
}
- BIO_flush(databio);
+ (void)BIO_flush(databio);
BIO_set_flags(databio, BIO_FLAGS_MEM_RDONLY);
break;
@@ -90,5 +104,5 @@
exit (SCEP_PKISTATUS_P7);
}
- BIO_flush(databio);
+ (void)BIO_flush(databio);
BIO_set_flags(databio, BIO_FLAGS_MEM_RDONLY);
break;
@@ -100,5 +114,5 @@
/* Signer cert */
signercert = localcert;
- signercert = rsa;
+ signerkey = rsa;
/* Read data in memory bio */
@@ -111,5 +125,5 @@
exit (SCEP_PKISTATUS_P7);
}
- BIO_flush(databio);
+ (void)BIO_flush(databio);
BIO_set_flags(databio, BIO_FLAGS_MEM_RDONLY);
break;
@@ -121,5 +135,5 @@
/* Signer cert */
signercert = localcert;
- signercert = rsa;
+ signerkey = rsa;
/* Read data in memory bio */
@@ -132,5 +146,5 @@
exit (SCEP_PKISTATUS_P7);
}
- BIO_flush(databio);
+ (void)BIO_flush(databio);
BIO_set_flags(databio, BIO_FLAGS_MEM_RDONLY);
break;
@@ -195,5 +209,5 @@
exit (SCEP_PKISTATUS_P7);
}
- BIO_flush(memorybio);
+ (void)BIO_flush(memorybio);
BIO_set_flags(memorybio, BIO_FLAGS_MEM_RDONLY);
len = BIO_get_mem_data(memorybio, &buffer);
@@ -298,5 +312,5 @@
/* Copy PKCS#7 */
i2d_PKCS7_bio(outbio, s->request_p7);
- BIO_flush(outbio);
+ (void)BIO_flush(outbio);
BIO_set_flags(memorybio, BIO_FLAGS_MEM_RDONLY);
s->request_len = BIO_get_mem_data(memorybio, &s->request_payload);
@@ -370,5 +384,5 @@
BIO_write(outbio, buffer, bytes);
}
- BIO_flush(outbio);
+ (void)BIO_flush(outbio);
if (v_flag)
printf("%s: PKCS#7 contains %d bytes of enveloped data\n",
@@ -584,5 +598,5 @@
exit (SCEP_PKISTATUS_P7);
}
- BIO_flush(outbio);
+ (void)BIO_flush(outbio);
/* Write decrypted data */
@@ -599,6 +613,6 @@
/* Add signed attributes */
-int
-add_attribute_string(STACK_OF(X509_ATTRIBUTE) *attrs, int nid, char *buffer) {
+static int
+add_attribute_string(STACK_OF(X509_ATTRIBUTE) *attrs, int nid, const char *buffer) {
ASN1_STRING *asn1_string = NULL;
X509_ATTRIBUTE *x509_a;
@@ -623,6 +637,6 @@
}
-int
-add_attribute_octet(STACK_OF(X509_ATTRIBUTE) *attrs, int nid, char *buffer,
+static int
+add_attribute_octet(STACK_OF(X509_ATTRIBUTE) *attrs, int nid, const char *buffer,
int len) {
ASN1_STRING *asn1_string = NULL;
--- ias.c 2006-03-13 06:45:20.000000000 -0500
+++ ias.c 2008-04-29 10:03:02.000000000 -0400
@@ -15,7 +15,8 @@
#include "ias.h"
-int i2d_pkcs7_issuer_and_subject(pkcs7_issuer_and_subject *a,
+int i2d_pkcs7_issuer_and_subject(void *pv,
unsigned char **pp) {
+ pkcs7_issuer_and_subject *a = pv;
M_ASN1_I2D_vars(a);
M_ASN1_I2D_len(a->issuer,i2d_X509_NAME);
--- sceputils.c 2006-03-13 06:45:22.000000000 -0500
+++ sceputils.c 2008-05-03 12:35:42.000000000 -0400
@@ -48,5 +48,5 @@
*/
int new_selfsigned(struct scep *s) {
- unsigned char *ptr;
+ const unsigned char *ptr;
X509 *cert;
X509_NAME *subject;
@@ -99,6 +99,11 @@
}
/* Get serial no from transaction id */
- ptr = (unsigned char *)s->transaction_id;
- if (!(serial = c2i_ASN1_INTEGER(NULL, &ptr, 32))) {
+ ptr = (const unsigned char *)s->transaction_id;
+#if OPENSSL_VERSION_NUMBER < 0x0090800fL
+# define CAST_CRUTCH (unsigned char **)
+#else
+# define CAST_CRUTCH
+#endif
+ if (!(serial = c2i_ASN1_INTEGER(NULL, CAST_CRUTCH&ptr, 32))) {
fprintf(stderr, "%s: error converting serial\n", pname);
ERR_print_errors_fp(stderr);
@@ -231,5 +236,5 @@
/* Assign space for ASCII presentation of the digest */
- str = (unsigned char *)malloc(2 * MD5_DIGEST_LENGTH + 1);
+ str = malloc(2 * MD5_DIGEST_LENGTH + 1); /* XXX this is never freed */
ret = str;
@@ -246,5 +251,5 @@
/* Copy as ASCII string and return: */
for (c = 0; c < MD5_DIGEST_LENGTH; c++, str += 2) {
- sprintf((char *)str, "%02X", md[c]);
+ sprintf(str, "%02X", md[c]);
}
@@ -252,4 +257,2 @@
return(ret);
}
-
-
--- sscep.h 2007-12-27 01:15:38.000000000 -0500
+++ sscep.h 2008-04-29 10:03:02.000000000 -0400
@@ -139,7 +139,7 @@
/* Fingerprint, signing and encryption algorithms */
-EVP_MD *fp_alg;
-EVP_MD *sig_alg;
-EVP_CIPHER *enc_alg;
+const EVP_MD *fp_alg;
+const EVP_MD *sig_alg;
+const EVP_CIPHER *enc_alg;
/* OpenSSL OID handles */
@@ -188,5 +188,5 @@
/* SCEP message types */
int request_type;
- char *request_type_str;
+ const char *request_type_str;
int reply_type;
char *reply_type_str;
@@ -199,5 +199,5 @@
/* SCEP transaction attributes */
- char *transaction_id;
+ const char *transaction_id;
unsigned char *sender_nonce;
int sender_nonce_len;
@@ -237,7 +237,4 @@
int send_msg (struct http_reply *, char *, char *, int, int);
-/* Catch SIGALRM */
-void catchalarm (int);
-
/* Get config file parameter */
char *get_string (char *);
@@ -291,10 +288,4 @@
int pkcs7_unwrap(struct scep *);
-/* Add signed string attribute */
-int add_attribute_string(STACK_OF(X509_ATTRIBUTE) *, int, char *);
-
-/* Add signed octet attribute */
-int add_attribute_octet(STACK_OF(X509_ATTRIBUTE) *, int, char *, int);
-
/* Find signed attributes */
int get_signed_attribute(STACK_OF(X509_ATTRIBUTE) *, int, int, char **);
@@ -302,5 +293,5 @@
/* URL-endcode */
-char *url_encode (char *, size_t);
+char *url_encode (const char *, size_t);
/* End of Functions */
--- cmd.h 2006-03-13 06:45:14.000000000 -0500
+++ cmd.h 2008-04-29 10:03:02.000000000 -0400
@@ -45,5 +45,5 @@
/* CA identifier */
-char *i_char;
+const char *i_char;
int i_flag;
--- sscep.c 2007-12-27 01:08:39.000000000 -0500
+++ sscep.c 2008-04-29 10:03:15.000000000 -0400
@@ -64,4 +64,10 @@
} /* handle_serial */
+static void
+catchalarm(int signo __unused) {
+ fprintf(stderr, "%s: connection timed out\n", pname);
+ exit (SCEP_PKISTATUS_TIMEOUT);
+}
+
int
main(int argc, char **argv) {
@@ -349,11 +355,11 @@
/* Check algorithms */
if (!E_flag) {
- enc_alg = (EVP_CIPHER *)EVP_des_cbc();
+ enc_alg = EVP_des_cbc();
} else if (!strncmp(E_char, "blowfish", 8)) {
- enc_alg = (EVP_CIPHER *)EVP_bf_cbc();
+ enc_alg = EVP_bf_cbc();
} else if (!strncmp(E_char, "des", 3)) {
- enc_alg = (EVP_CIPHER *)EVP_des_cbc();
+ enc_alg = EVP_des_cbc();
} else if (!strncmp(E_char, "3des", 4)) {
- enc_alg = (EVP_CIPHER *)EVP_des_ede3_cbc();
+ enc_alg = EVP_des_ede3_cbc();
} else {
fprintf(stderr, "%s: unsupported algorithm: %s\n",
@@ -362,9 +368,9 @@
}
if (!S_flag) {
- sig_alg = (EVP_MD *)EVP_md5();
+ sig_alg = EVP_md5();
} else if (!strncmp(S_char, "md5", 3)) {
- sig_alg = (EVP_MD *)EVP_md5();
+ sig_alg = EVP_md5();
} else if (!strncmp(S_char, "sha1", 4)) {
- sig_alg = (EVP_MD *)EVP_sha1();
+ sig_alg = EVP_sha1();
} else {
fprintf(stderr, "%s: unsupported algorithm: %s\n",
@@ -374,9 +380,9 @@
/* Fingerprint algorithm */
if (!F_flag) {
- fp_alg = (EVP_MD *)EVP_md5();
+ fp_alg = EVP_md5();
} else if (!strncmp(F_char, "md5", 3)) {
- fp_alg = (EVP_MD *)EVP_md5();
+ fp_alg = EVP_md5();
} else if (!strncmp(F_char, "sha1", 4)) {
- fp_alg = (EVP_MD *)EVP_sha1();
+ fp_alg = EVP_sha1();
} else {
fprintf(stderr, "%s: unsupported algorithm: %s\n",
@@ -778,8 +784,2 @@
exit(0);
}
-
-void
-catchalarm(int signo) {
- fprintf(stderr, "%s: connection timed out\n", pname);
- exit (SCEP_PKISTATUS_TIMEOUT);
-}
|