diff options
Diffstat (limited to 'src/lib/libcrypto/pkcs7/example.c')
-rw-r--r-- | src/lib/libcrypto/pkcs7/example.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/lib/libcrypto/pkcs7/example.c b/src/lib/libcrypto/pkcs7/example.c index 7354890084..f6656be28e 100644 --- a/src/lib/libcrypto/pkcs7/example.c +++ b/src/lib/libcrypto/pkcs7/example.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <string.h> | ||
3 | #include <openssl/pkcs7.h> | 4 | #include <openssl/pkcs7.h> |
4 | #include <openssl/asn1_mac.h> | 5 | #include <openssl/asn1_mac.h> |
5 | 6 | ||
@@ -36,7 +37,7 @@ void add_signed_string(PKCS7_SIGNER_INFO *si, char *str) | |||
36 | signed_string_nid= | 37 | signed_string_nid= |
37 | OBJ_create("1.2.3.4.5","OID_example","Our example OID"); | 38 | OBJ_create("1.2.3.4.5","OID_example","Our example OID"); |
38 | os=ASN1_OCTET_STRING_new(); | 39 | os=ASN1_OCTET_STRING_new(); |
39 | ASN1_OCTET_STRING_set(os,str,strlen(str)); | 40 | ASN1_OCTET_STRING_set(os,(unsigned char*)str,strlen(str)); |
40 | /* When we add, we do not free */ | 41 | /* When we add, we do not free */ |
41 | PKCS7_add_signed_attribute(si,signed_string_nid, | 42 | PKCS7_add_signed_attribute(si,signed_string_nid, |
42 | V_ASN1_OCTET_STRING,(char *)os); | 43 | V_ASN1_OCTET_STRING,(char *)os); |
@@ -68,7 +69,7 @@ int get_signed_string(PKCS7_SIGNER_INFO *si, char *buf, int len) | |||
68 | return(0); | 69 | return(0); |
69 | } | 70 | } |
70 | 71 | ||
71 | static signed_seq2string_nid= -1; | 72 | static int signed_seq2string_nid= -1; |
72 | /* ########################################### */ | 73 | /* ########################################### */ |
73 | int add_signed_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2) | 74 | int add_signed_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2) |
74 | { | 75 | { |
@@ -86,8 +87,8 @@ int add_signed_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2) | |||
86 | 87 | ||
87 | os1=ASN1_OCTET_STRING_new(); | 88 | os1=ASN1_OCTET_STRING_new(); |
88 | os2=ASN1_OCTET_STRING_new(); | 89 | os2=ASN1_OCTET_STRING_new(); |
89 | ASN1_OCTET_STRING_set(os1,str1,strlen(str1)); | 90 | ASN1_OCTET_STRING_set(os1,(unsigned char*)str1,strlen(str1)); |
90 | ASN1_OCTET_STRING_set(os2,str1,strlen(str1)); | 91 | ASN1_OCTET_STRING_set(os2,(unsigned char*)str1,strlen(str1)); |
91 | i =i2d_ASN1_OCTET_STRING(os1,NULL); | 92 | i =i2d_ASN1_OCTET_STRING(os1,NULL); |
92 | i+=i2d_ASN1_OCTET_STRING(os2,NULL); | 93 | i+=i2d_ASN1_OCTET_STRING(os2,NULL); |
93 | total=ASN1_object_size(1,i,V_ASN1_SEQUENCE); | 94 | total=ASN1_object_size(1,i,V_ASN1_SEQUENCE); |
@@ -197,7 +198,7 @@ X509_ATTRIBUTE *create_string(char *str) | |||
197 | signed_string_nid= | 198 | signed_string_nid= |
198 | OBJ_create("1.2.3.4.5","OID_example","Our example OID"); | 199 | OBJ_create("1.2.3.4.5","OID_example","Our example OID"); |
199 | os=ASN1_OCTET_STRING_new(); | 200 | os=ASN1_OCTET_STRING_new(); |
200 | ASN1_OCTET_STRING_set(os,str,strlen(str)); | 201 | ASN1_OCTET_STRING_set(os,(unsigned char*)str,strlen(str)); |
201 | /* When we add, we do not free */ | 202 | /* When we add, we do not free */ |
202 | ret=X509_ATTRIBUTE_create(signed_string_nid, | 203 | ret=X509_ATTRIBUTE_create(signed_string_nid, |
203 | V_ASN1_OCTET_STRING,(char *)os); | 204 | V_ASN1_OCTET_STRING,(char *)os); |
@@ -250,8 +251,8 @@ X509_ATTRIBUTE *add_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2) | |||
250 | 251 | ||
251 | os1=ASN1_OCTET_STRING_new(); | 252 | os1=ASN1_OCTET_STRING_new(); |
252 | os2=ASN1_OCTET_STRING_new(); | 253 | os2=ASN1_OCTET_STRING_new(); |
253 | ASN1_OCTET_STRING_set(os1,str1,strlen(str1)); | 254 | ASN1_OCTET_STRING_set(os1,(unsigned char*)str1,strlen(str1)); |
254 | ASN1_OCTET_STRING_set(os2,str1,strlen(str1)); | 255 | ASN1_OCTET_STRING_set(os2,(unsigned char*)str1,strlen(str1)); |
255 | i =i2d_ASN1_OCTET_STRING(os1,NULL); | 256 | i =i2d_ASN1_OCTET_STRING(os1,NULL); |
256 | i+=i2d_ASN1_OCTET_STRING(os2,NULL); | 257 | i+=i2d_ASN1_OCTET_STRING(os2,NULL); |
257 | total=ASN1_object_size(1,i,V_ASN1_SEQUENCE); | 258 | total=ASN1_object_size(1,i,V_ASN1_SEQUENCE); |