diff options
author | markus <> | 2002-09-05 12:51:52 +0000 |
---|---|---|
committer | markus <> | 2002-09-05 12:51:52 +0000 |
commit | 5514995a9d5ed91db089875adb509c7781357c0e (patch) | |
tree | 2484410a46ba6c05ef94c253da36fbceef990b64 /src/lib/libcrypto/pkcs7/example.c | |
parent | fd9566423b542798f5c8b06e68101a9ea5bb9885 (diff) | |
download | openbsd-5514995a9d5ed91db089875adb509c7781357c0e.tar.gz openbsd-5514995a9d5ed91db089875adb509c7781357c0e.tar.bz2 openbsd-5514995a9d5ed91db089875adb509c7781357c0e.zip |
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/pkcs7/example.c')
-rw-r--r-- | src/lib/libcrypto/pkcs7/example.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/lib/libcrypto/pkcs7/example.c b/src/lib/libcrypto/pkcs7/example.c index 7354890084..c993947cc3 100644 --- a/src/lib/libcrypto/pkcs7/example.c +++ b/src/lib/libcrypto/pkcs7/example.c | |||
@@ -1,7 +1,9 @@ | |||
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> |
6 | #include <openssl/x509.h> | ||
5 | 7 | ||
6 | int add_signed_time(PKCS7_SIGNER_INFO *si) | 8 | int add_signed_time(PKCS7_SIGNER_INFO *si) |
7 | { | 9 | { |
@@ -36,7 +38,7 @@ void add_signed_string(PKCS7_SIGNER_INFO *si, char *str) | |||
36 | signed_string_nid= | 38 | signed_string_nid= |
37 | OBJ_create("1.2.3.4.5","OID_example","Our example OID"); | 39 | OBJ_create("1.2.3.4.5","OID_example","Our example OID"); |
38 | os=ASN1_OCTET_STRING_new(); | 40 | os=ASN1_OCTET_STRING_new(); |
39 | ASN1_OCTET_STRING_set(os,str,strlen(str)); | 41 | ASN1_OCTET_STRING_set(os,(unsigned char*)str,strlen(str)); |
40 | /* When we add, we do not free */ | 42 | /* When we add, we do not free */ |
41 | PKCS7_add_signed_attribute(si,signed_string_nid, | 43 | PKCS7_add_signed_attribute(si,signed_string_nid, |
42 | V_ASN1_OCTET_STRING,(char *)os); | 44 | V_ASN1_OCTET_STRING,(char *)os); |
@@ -68,7 +70,7 @@ int get_signed_string(PKCS7_SIGNER_INFO *si, char *buf, int len) | |||
68 | return(0); | 70 | return(0); |
69 | } | 71 | } |
70 | 72 | ||
71 | static signed_seq2string_nid= -1; | 73 | static int signed_seq2string_nid= -1; |
72 | /* ########################################### */ | 74 | /* ########################################### */ |
73 | int add_signed_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2) | 75 | int add_signed_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2) |
74 | { | 76 | { |
@@ -86,8 +88,8 @@ int add_signed_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2) | |||
86 | 88 | ||
87 | os1=ASN1_OCTET_STRING_new(); | 89 | os1=ASN1_OCTET_STRING_new(); |
88 | os2=ASN1_OCTET_STRING_new(); | 90 | os2=ASN1_OCTET_STRING_new(); |
89 | ASN1_OCTET_STRING_set(os1,str1,strlen(str1)); | 91 | ASN1_OCTET_STRING_set(os1,(unsigned char*)str1,strlen(str1)); |
90 | ASN1_OCTET_STRING_set(os2,str1,strlen(str1)); | 92 | ASN1_OCTET_STRING_set(os2,(unsigned char*)str1,strlen(str1)); |
91 | i =i2d_ASN1_OCTET_STRING(os1,NULL); | 93 | i =i2d_ASN1_OCTET_STRING(os1,NULL); |
92 | i+=i2d_ASN1_OCTET_STRING(os2,NULL); | 94 | i+=i2d_ASN1_OCTET_STRING(os2,NULL); |
93 | total=ASN1_object_size(1,i,V_ASN1_SEQUENCE); | 95 | total=ASN1_object_size(1,i,V_ASN1_SEQUENCE); |
@@ -197,7 +199,7 @@ X509_ATTRIBUTE *create_string(char *str) | |||
197 | signed_string_nid= | 199 | signed_string_nid= |
198 | OBJ_create("1.2.3.4.5","OID_example","Our example OID"); | 200 | OBJ_create("1.2.3.4.5","OID_example","Our example OID"); |
199 | os=ASN1_OCTET_STRING_new(); | 201 | os=ASN1_OCTET_STRING_new(); |
200 | ASN1_OCTET_STRING_set(os,str,strlen(str)); | 202 | ASN1_OCTET_STRING_set(os,(unsigned char*)str,strlen(str)); |
201 | /* When we add, we do not free */ | 203 | /* When we add, we do not free */ |
202 | ret=X509_ATTRIBUTE_create(signed_string_nid, | 204 | ret=X509_ATTRIBUTE_create(signed_string_nid, |
203 | V_ASN1_OCTET_STRING,(char *)os); | 205 | V_ASN1_OCTET_STRING,(char *)os); |
@@ -250,8 +252,8 @@ X509_ATTRIBUTE *add_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2) | |||
250 | 252 | ||
251 | os1=ASN1_OCTET_STRING_new(); | 253 | os1=ASN1_OCTET_STRING_new(); |
252 | os2=ASN1_OCTET_STRING_new(); | 254 | os2=ASN1_OCTET_STRING_new(); |
253 | ASN1_OCTET_STRING_set(os1,str1,strlen(str1)); | 255 | ASN1_OCTET_STRING_set(os1,(unsigned char*)str1,strlen(str1)); |
254 | ASN1_OCTET_STRING_set(os2,str1,strlen(str1)); | 256 | ASN1_OCTET_STRING_set(os2,(unsigned char*)str1,strlen(str1)); |
255 | i =i2d_ASN1_OCTET_STRING(os1,NULL); | 257 | i =i2d_ASN1_OCTET_STRING(os1,NULL); |
256 | i+=i2d_ASN1_OCTET_STRING(os2,NULL); | 258 | i+=i2d_ASN1_OCTET_STRING(os2,NULL); |
257 | total=ASN1_object_size(1,i,V_ASN1_SEQUENCE); | 259 | total=ASN1_object_size(1,i,V_ASN1_SEQUENCE); |