Changes between 0.9.3a and 0.9.4
+ *) Make S/MIME samples compile (not yet tested).
+ [Ben Laurie]
+
*) Additional typesafe stacks.
[Ben Laurie]
all: lib
+testapps: enc dec sign verify
+
+enc: enc.o lib
+ $(CC) $(CFLAGS) -o enc enc.o $(LIB)
+
+dec: dec.o lib
+ $(CC) $(CFLAGS) -o dec dec.o $(LIB)
+
+sign: sign.o lib
+ $(CC) $(CFLAGS) -o sign sign.o $(LIB)
+
+verify: verify.o example.o lib
+ $(CC) $(CFLAGS) -o verify verify.o example.o $(LIB)
+
lib: $(LIBOBJ)
$(AR) $(LIB) $(LIBOBJ)
$(RANLIB) $(LIB)
int argc;
char *argv[];
{
- char *keyfile;
+ char *keyfile=NULL;
BIO *in;
EVP_PKEY *pkey;
X509 *x509;
char buf[1024*4];
unsigned char *pp;
int i,printit=0;
- STACK *sk;
+ STACK_OF(PKCS7_SIGNER_INFO) *sk;
SSLeay_add_all_algorithms();
bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
/* Ok, first we need to, for each subject entry,
* see if we can verify */
ERR_clear_error();
- for (i=0; i<sk_num(sk); i++)
+ for (i=0; i<sk_PKCS7_SIGNER_INFO_num(sk); i++)
{
- si=(PKCS7_SIGNER_INFO *)sk_value(sk,i);
+ si=sk_PKCS7_SIGNER_INFO_value(sk,i);
i=PKCS7_dataVerify(cert_store,&cert_ctx,p7bio,p7,si);
if (i <= 0)
goto err;
int i;
int nodetach=1;
char *keyfile = NULL;
- const EVP_CIPHER *cipher;
+ const EVP_CIPHER *cipher=NULL;
SSLeay_add_all_algorithms();
#include <stdio.h>
#include <stdlib.h>
-#include <malloc.h>
#include <openssl/pkcs7.h>
+#include <openssl/asn1_mac.h>
int add_signed_time(PKCS7_SIGNER_INFO *si)
{
ASN1_UTCTIME *get_signed_time(PKCS7_SIGNER_INFO *si)
{
ASN1_TYPE *so;
- ASN1_UTCTIME *ut;
so=PKCS7_get_signed_attribute(si,NID_pkcs9_signingTime);
if (so->type == V_ASN1_UTCTIME)
- {
- ut=so->value.utctime;
- }
- return(ut);
+ return so->value.utctime;
+ return NULL;
}
static int signed_string_nid= -1;
-int add_signed_string(PKCS7_SIGNER_INFO *si, char *str)
+void add_signed_string(PKCS7_SIGNER_INFO *si, char *str)
{
ASN1_OCTET_STRING *os;
unsigned char *p;
ASN1_OCTET_STRING *os1,*os2;
ASN1_STRING *seq;
- char *data;
+ unsigned char *data;
int i,total;
if (signed_seq2string_nid == -1)
return(ret);
}
-ASN1_UTCTIME *sk_get_time(STACK *sk)
+ASN1_UTCTIME *sk_get_time(STACK_OF(X509_ATTRIBUTE) *sk)
{
ASN1_TYPE *so;
- ASN1_UTCTIME *ut;
PKCS7_SIGNER_INFO si;
si.auth_attr=sk;
so=PKCS7_get_signed_attribute(&si,NID_pkcs9_signingTime);
if (so->type == V_ASN1_UTCTIME)
- {
- ut=so->value.utctime;
- }
- return(ut);
+ return so->value.utctime;
+ return NULL;
}
X509_ATTRIBUTE *create_string(char *str)
return(ret);
}
-int sk_get_string(STACK *sk, char *buf, int len)
+int sk_get_string(STACK_OF(X509_ATTRIBUTE) *sk, char *buf, int len)
{
ASN1_TYPE *so;
ASN1_OCTET_STRING *os;
ASN1_OCTET_STRING *os1,*os2;
ASN1_STRING *seq;
X509_ATTRIBUTE *ret;
- char *data;
+ unsigned char *data;
int i,total;
if (signed_seq2string_nid == -1)
}
/* For this case, I will malloc the return strings */
-int sk_get_seq2string(STACK *sk, char **str1, char **str2)
+int sk_get_seq2string(STACK_OF(X509_ATTRIBUTE) *sk, char **str1, char **str2)
{
ASN1_TYPE *so;
PKCS7_SIGNER_INFO si;
--- /dev/null
+/* ====================================================================
+ * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+int add_signed_time(PKCS7_SIGNER_INFO *si);
+ASN1_UTCTIME *get_signed_time(PKCS7_SIGNER_INFO *si);
+int get_signed_seq2string(PKCS7_SIGNER_INFO *si, char **str1, char **str2);
#include <openssl/bio.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
+#include <openssl/err.h>
-main(argc,argv)
+int main(argc,argv)
int argc;
char *argv[];
{
X509 *x509;
EVP_PKEY *pkey;
PKCS7 *p7;
- PKCS7 *p7_data;
PKCS7_SIGNER_INFO *si;
BIO *in;
BIO *data,*p7bio;
char buf[1024*4];
- int i,j;
+ int i;
int nodetach=0;
EVP_add_digest(EVP_md2());
* [including the GNU Public Licence.]
*/
#include <stdio.h>
-#include <openssl/asn1.h>
#include <openssl/bio.h>
+#include <openssl/asn1.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
+#include <openssl/err.h>
+#include "example.h"
int verify_callback(int ok, X509_STORE_CTX *ctx);
BIO *bio_err=NULL;
BIO *bio_out=NULL;
-main(argc,argv)
+int main(argc,argv)
int argc;
char *argv[];
{
- X509 *x509,*x;
PKCS7 *p7;
- PKCS7_SIGNED *s;
PKCS7_SIGNER_INFO *si;
- PKCS7_ISSUER_AND_SERIAL *ias;
X509_STORE_CTX cert_ctx;
X509_STORE *cert_store=NULL;
- X509_LOOKUP *lookup=NULL;
BIO *data,*detached=NULL,*p7bio=NULL;
char buf[1024*4];
- unsigned char *p,*pp;
- int i,j,printit=0;
- STACK *sk;
+ char *pp;
+ int i,printit=0;
+ STACK_OF(PKCS7_SIGNER_INFO) *sk;
bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
bio_out=BIO_new_fp(stdout,BIO_NOCLOSE);
EVP_add_digest(EVP_mdc2());
data=BIO_new(BIO_s_file());
-again:
+
pp=NULL;
while (argc > 1)
{
}
/* Ok, first we need to, for each subject entry, see if we can verify */
- for (i=0; i<sk_num(sk); i++)
+ for (i=0; i<sk_PKCS7_SIGNER_INFO_num(sk); i++)
{
ASN1_UTCTIME *tm;
char *str1,*str2;
- si=(PKCS7_SIGNER_INFO *)sk_value(sk,i);
+ si=sk_PKCS7_SIGNER_INFO_value(sk,i);
i=PKCS7_dataVerify(cert_store,&cert_ctx,p7bio,p7,si);
if (i <= 0)
goto err;