summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/pkcs7/example.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/pkcs7/example.c')
-rw-r--r--src/lib/libcrypto/pkcs7/example.c16
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
6int add_signed_time(PKCS7_SIGNER_INFO *si) 8int 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
71static signed_seq2string_nid= -1; 73static int signed_seq2string_nid= -1;
72/* ########################################### */ 74/* ########################################### */
73int add_signed_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2) 75int 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);