diff options
author | Matt Caswell <matt@openssl.org> | 2015-01-22 02:47:42 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2015-01-22 09:52:55 +0000 |
commit | 40720ce3caf44294b5b87a18856b7aef06123314 (patch) | |
tree | 30d57dec407c05fe6ea57275517805e8c79a7dcc /demos | |
parent | 9d03aabea3ead1fe6a194297ddffd4a87f89b93c (diff) |
Run util/openssl-format-source -v -c .
Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'demos')
40 files changed, 8196 insertions, 7950 deletions
diff --git a/demos/asn1/ocsp.c b/demos/asn1/ocsp.c index e2535f3cf6..db40719895 100644 --- a/demos/asn1/ocsp.c +++ b/demos/asn1/ocsp.c @@ -1,6 +1,7 @@ /* ocsp.c */ -/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL - * project 2000. +/* + * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project + * 2000. */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. @@ -10,7 +11,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * 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 @@ -59,114 +60,111 @@ #include <openssl/asn1t.h> #include <openssl/x509v3.h> - - - -/*- +/*- Example of new ASN1 code, OCSP request - OCSPRequest ::= SEQUENCE { - tbsRequest TBSRequest, - optionalSignature [0] EXPLICIT Signature OPTIONAL } - - TBSRequest ::= SEQUENCE { - version [0] EXPLICIT Version DEFAULT v1, - requestorName [1] EXPLICIT GeneralName OPTIONAL, - requestList SEQUENCE OF Request, - requestExtensions [2] EXPLICIT Extensions OPTIONAL } - - Signature ::= SEQUENCE { - signatureAlgorithm AlgorithmIdentifier, - signature BIT STRING, - certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } - - Version ::= INTEGER { v1(0) } - - Request ::= SEQUENCE { - reqCert CertID, - singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL } - - CertID ::= SEQUENCE { - hashAlgorithm AlgorithmIdentifier, - issuerNameHash OCTET STRING, -- Hash of Issuer's DN - issuerKeyHash OCTET STRING, -- Hash of Issuers public key - serialNumber CertificateSerialNumber } - - OCSPResponse ::= SEQUENCE { - responseStatus OCSPResponseStatus, - responseBytes [0] EXPLICIT ResponseBytes OPTIONAL } - - OCSPResponseStatus ::= ENUMERATED { - successful (0), --Response has valid confirmations - malformedRequest (1), --Illegal confirmation request - internalError (2), --Internal error in issuer - tryLater (3), --Try again later - --(4) is not used - sigRequired (5), --Must sign the request - unauthorized (6) --Request unauthorized - } - - ResponseBytes ::= SEQUENCE { - responseType OBJECT IDENTIFIER, - response OCTET STRING } - - BasicOCSPResponse ::= SEQUENCE { - tbsResponseData ResponseData, - signatureAlgorithm AlgorithmIdentifier, - signature BIT STRING, - certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } - - ResponseData ::= SEQUENCE { - version [0] EXPLICIT Version DEFAULT v1, - responderID ResponderID, - producedAt GeneralizedTime, - responses SEQUENCE OF SingleResponse, - responseExtensions [1] EXPLICIT Extensions OPTIONAL } - - ResponderID ::= CHOICE { - byName [1] Name, --EXPLICIT - byKey [2] KeyHash } - - KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key - --(excluding the tag and length fields) - - SingleResponse ::= SEQUENCE { - certID CertID, - certStatus CertStatus, - thisUpdate GeneralizedTime, - nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL, - singleExtensions [1] EXPLICIT Extensions OPTIONAL } - - CertStatus ::= CHOICE { - good [0] IMPLICIT NULL, - revoked [1] IMPLICIT RevokedInfo, - unknown [2] IMPLICIT UnknownInfo } - - RevokedInfo ::= SEQUENCE { - revocationTime GeneralizedTime, - revocationReason [0] EXPLICIT CRLReason OPTIONAL } - - UnknownInfo ::= NULL -- this can be replaced with an enumeration - - ArchiveCutoff ::= GeneralizedTime - - AcceptableResponses ::= SEQUENCE OF OBJECT IDENTIFIER - - ServiceLocator ::= SEQUENCE { - issuer Name, - locator AuthorityInfoAccessSyntax } - - -- Object Identifiers - - id-kp-OCSPSigning OBJECT IDENTIFIER ::= { id-kp 9 } - id-pkix-ocsp OBJECT IDENTIFIER ::= { id-ad-ocsp } - id-pkix-ocsp-basic OBJECT IDENTIFIER ::= { id-pkix-ocsp 1 } - id-pkix-ocsp-nonce OBJECT IDENTIFIER ::= { id-pkix-ocsp 2 } - id-pkix-ocsp-crl OBJECT IDENTIFIER ::= { id-pkix-ocsp 3 } - id-pkix-ocsp-response OBJECT IDENTIFIER ::= { id-pkix-ocsp 4 } - id-pkix-ocsp-nocheck OBJECT IDENTIFIER ::= { id-pkix-ocsp 5 } - id-pkix-ocsp-archive-cutoff OBJECT IDENTIFIER ::= { id-pkix-ocsp 6 } - id-pkix-ocsp-service-locator OBJECT IDENTIFIER ::= { id-pkix-ocsp 7 } + OCSPRequest ::= SEQUENCE { + tbsRequest TBSRequest, + optionalSignature [0] EXPLICIT Signature OPTIONAL } + + TBSRequest ::= SEQUENCE { + version [0] EXPLICIT Version DEFAULT v1, + requestorName [1] EXPLICIT GeneralName OPTIONAL, + requestList SEQUENCE OF Request, + requestExtensions [2] EXPLICIT Extensions OPTIONAL } + + Signature ::= SEQUENCE { + signatureAlgorithm AlgorithmIdentifier, + signature BIT STRING, + certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } + + Version ::= INTEGER { v1(0) } + + Request ::= SEQUENCE { + reqCert CertID, + singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL } + + CertID ::= SEQUENCE { + hashAlgorithm AlgorithmIdentifier, + issuerNameHash OCTET STRING, -- Hash of Issuer's DN + issuerKeyHash OCTET STRING, -- Hash of Issuers public key + serialNumber CertificateSerialNumber } + + OCSPResponse ::= SEQUENCE { + responseStatus OCSPResponseStatus, + responseBytes [0] EXPLICIT ResponseBytes OPTIONAL } + + OCSPResponseStatus ::= ENUMERATED { + successful (0), --Response has valid confirmations + malformedRequest (1), --Illegal confirmation request + internalError (2), --Internal error in issuer + tryLater (3), --Try again later + --(4) is not used + sigRequired (5), --Must sign the request + unauthorized (6) --Request unauthorized + } + + ResponseBytes ::= SEQUENCE { + responseType OBJECT IDENTIFIER, + response OCTET STRING } + + BasicOCSPResponse ::= SEQUENCE { + tbsResponseData ResponseData, + signatureAlgorithm AlgorithmIdentifier, + signature BIT STRING, + certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } + + ResponseData ::= SEQUENCE { + version [0] EXPLICIT Version DEFAULT v1, + responderID ResponderID, + producedAt GeneralizedTime, + responses SEQUENCE OF SingleResponse, + responseExtensions [1] EXPLICIT Extensions OPTIONAL } + + ResponderID ::= CHOICE { + byName [1] Name, --EXPLICIT + byKey [2] KeyHash } + + KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key + --(excluding the tag and length fields) + + SingleResponse ::= SEQUENCE { + certID CertID, + certStatus CertStatus, + thisUpdate GeneralizedTime, + nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL, + singleExtensions [1] EXPLICIT Extensions OPTIONAL } + + CertStatus ::= CHOICE { + good [0] IMPLICIT NULL, + revoked [1] IMPLICIT RevokedInfo, + unknown [2] IMPLICIT UnknownInfo } + + RevokedInfo ::= SEQUENCE { + revocationTime GeneralizedTime, + revocationReason [0] EXPLICIT CRLReason OPTIONAL } + + UnknownInfo ::= NULL -- this can be replaced with an enumeration + + ArchiveCutoff ::= GeneralizedTime + + AcceptableResponses ::= SEQUENCE OF OBJECT IDENTIFIER + + ServiceLocator ::= SEQUENCE { + issuer Name, + locator AuthorityInfoAccessSyntax } + + -- Object Identifiers + + id-kp-OCSPSigning OBJECT IDENTIFIER ::= { id-kp 9 } + id-pkix-ocsp OBJECT IDENTIFIER ::= { id-ad-ocsp } + id-pkix-ocsp-basic OBJECT IDENTIFIER ::= { id-pkix-ocsp 1 } + id-pkix-ocsp-nonce OBJECT IDENTIFIER ::= { id-pkix-ocsp 2 } + id-pkix-ocsp-crl OBJECT IDENTIFIER ::= { id-pkix-ocsp 3 } + id-pkix-ocsp-response OBJECT IDENTIFIER ::= { id-pkix-ocsp 4 } + id-pkix-ocsp-nocheck OBJECT IDENTIFIER ::= { id-pkix-ocsp 5 } + id-pkix-ocsp-archive-cutoff OBJECT IDENTIFIER ::= { id-pkix-ocsp 6 } + id-pkix-ocsp-service-locator OBJECT IDENTIFIER ::= { id-pkix-ocsp 7 } */ @@ -175,193 +173,189 @@ DECLARE_STACK_OF(Request) typedef struct { - ASN1_INTEGER *version; - GENERAL_NAME *requestorName; - STACK_OF(Request) *requestList; - STACK_OF(X509_EXTENSION) *requestExtensions; + ASN1_INTEGER *version; + GENERAL_NAME *requestorName; + STACK_OF(Request) *requestList; + STACK_OF(X509_EXTENSION) *requestExtensions; } TBSRequest; typedef struct { - X509_ALGOR *signatureAlgorithm; - ASN1_BIT_STRING *signature; - STACK_OF(X509) *certs; + X509_ALGOR *signatureAlgorithm; + ASN1_BIT_STRING *signature; + STACK_OF(X509) *certs; } Signature; typedef struct { - TBSRequest *tbsRequest; - Signature *optionalSignature; + TBSRequest *tbsRequest; + Signature *optionalSignature; } OCSPRequest; typedef struct { - X509_ALGOR *hashAlgorithm; - ASN1_OCTET_STRING *issuerNameHash; - ASN1_OCTET_STRING *issuerKeyHash; - ASN1_INTEGER *certificateSerialNumber; + X509_ALGOR *hashAlgorithm; + ASN1_OCTET_STRING *issuerNameHash; + ASN1_OCTET_STRING *issuerKeyHash; + ASN1_INTEGER *certificateSerialNumber; } CertID; typedef struct { - CertID *reqCert; - STACK_OF(X509_EXTENSION) *singleRequestExtensions; + CertID *reqCert; + STACK_OF(X509_EXTENSION) *singleRequestExtensions; } Request; /* Response structures */ typedef struct { - ASN1_OBJECT *responseType; - ASN1_OCTET_STRING *response; + ASN1_OBJECT *responseType; + ASN1_OCTET_STRING *response; } ResponseBytes; typedef struct { - ASN1_ENUMERATED *responseStatus; - ResponseBytes *responseBytes; + ASN1_ENUMERATED *responseStatus; + ResponseBytes *responseBytes; } OCSPResponse; typedef struct { - int type; - union { - X509_NAME *byName; - ASN1_OCTET_STRING *byKey; - }d; + int type; + union { + X509_NAME *byName; + ASN1_OCTET_STRING *byKey; + } d; } ResponderID; typedef struct { - ASN1_INTEGER *version; - ResponderID *responderID; - ASN1_GENERALIZEDTIME *producedAt; - STACK_OF(SingleResponse) *responses; - STACK_OF(X509_EXTENSION) *responseExtensions; + ASN1_INTEGER *version; + ResponderID *responderID; + ASN1_GENERALIZEDTIME *producedAt; + STACK_OF(SingleResponse) *responses; + STACK_OF(X509_EXTENSION) *responseExtensions; } ResponseData; typedef struct { - ResponseData *tbsResponseData; - X509_ALGOR *signatureAlgorithm; - ASN1_BIT_STRING *signature; - STACK_OF(X509) *certs; + ResponseData *tbsResponseData; + X509_ALGOR *signatureAlgorithm; + ASN1_BIT_STRING *signature; + STACK_OF(X509) *certs; } BasicOCSPResponse; typedef struct { - ASN1_GENERALIZEDTIME *revocationTime; - ASN1_ENUMERATED * revocationReason; + ASN1_GENERALIZEDTIME *revocationTime; + ASN1_ENUMERATED *revocationReason; } RevokedInfo; typedef struct { - int type; - union { - ASN1_NULL *good; - RevokedInfo *revoked; - ASN1_NULL *unknown; - } d; + int type; + union { + ASN1_NULL *good; + RevokedInfo *revoked; + ASN1_NULL *unknown; + } d; } CertStatus; typedef struct { - CertID *certID; - CertStatus *certStatus; - ASN1_GENERALIZEDTIME *thisUpdate; - ASN1_GENERALIZEDTIME *nextUpdate; - STACK_OF(X509_EXTENSION) *singleExtensions; + CertID *certID; + CertStatus *certStatus; + ASN1_GENERALIZEDTIME *thisUpdate; + ASN1_GENERALIZEDTIME *nextUpdate; + STACK_OF(X509_EXTENSION) *singleExtensions; } SingleResponse; - typedef struct { X509_NAME *issuer; STACK_OF(ACCESS_DESCRIPTION) *locator; } ServiceLocator; - /* Now the ASN1 templates */ IMPLEMENT_COMPAT_ASN1(X509); IMPLEMENT_COMPAT_ASN1(X509_ALGOR); -//IMPLEMENT_COMPAT_ASN1(X509_EXTENSION); +// IMPLEMENT_COMPAT_ASN1(X509_EXTENSION); IMPLEMENT_COMPAT_ASN1(GENERAL_NAME); IMPLEMENT_COMPAT_ASN1(X509_NAME); ASN1_SEQUENCE(X509_EXTENSION) = { - ASN1_SIMPLE(X509_EXTENSION, object, ASN1_OBJECT), - ASN1_OPT(X509_EXTENSION, critical, ASN1_BOOLEAN), - ASN1_SIMPLE(X509_EXTENSION, value, ASN1_OCTET_STRING) + ASN1_SIMPLE(X509_EXTENSION, object, ASN1_OBJECT), + ASN1_OPT(X509_EXTENSION, critical, ASN1_BOOLEAN), + ASN1_SIMPLE(X509_EXTENSION, value, ASN1_OCTET_STRING) } ASN1_SEQUENCE_END(X509_EXTENSION); - + ASN1_SEQUENCE(Signature) = { - ASN1_SIMPLE(Signature, signatureAlgorithm, X509_ALGOR), - ASN1_SIMPLE(Signature, signature, ASN1_BIT_STRING), - ASN1_SEQUENCE_OF(Signature, certs, X509) + ASN1_SIMPLE(Signature, signatureAlgorithm, X509_ALGOR), + ASN1_SIMPLE(Signature, signature, ASN1_BIT_STRING), + ASN1_SEQUENCE_OF(Signature, certs, X509) } ASN1_SEQUENCE_END(Signature); ASN1_SEQUENCE(CertID) = { - ASN1_SIMPLE(CertID, hashAlgorithm, X509_ALGOR), - ASN1_SIMPLE(CertID, issuerNameHash, ASN1_OCTET_STRING), - ASN1_SIMPLE(CertID, issuerKeyHash, ASN1_OCTET_STRING), - ASN1_SIMPLE(CertID, certificateSerialNumber, ASN1_INTEGER) + ASN1_SIMPLE(CertID, hashAlgorithm, X509_ALGOR), + ASN1_SIMPLE(CertID, issuerNameHash, ASN1_OCTET_STRING), + ASN1_SIMPLE(CertID, issuerKeyHash, ASN1_OCTET_STRING), + ASN1_SIMPLE(CertID, certificateSerialNumber, ASN1_INTEGER) } ASN1_SEQUENCE_END(CertID); ASN1_SEQUENCE(Request) = { - ASN1_SIMPLE(Request, reqCert, CertID), - ASN1_EXP_SEQUENCE_OF_OPT(Request, singleRequestExtensions, X509_EXTENSION, 0) + ASN1_SIMPLE(Request, reqCert, CertID), + ASN1_EXP_SEQUENCE_OF_OPT(Request, singleRequestExtensions, X509_EXTENSION, 0) } ASN1_SEQUENCE_END(Request); ASN1_SEQUENCE(TBSRequest) = { - ASN1_EXP_OPT(TBSRequest, version, ASN1_INTEGER, 0), - ASN1_EXP_OPT(TBSRequest, requestorName, GENERAL_NAME, 1), - ASN1_SEQUENCE_OF(TBSRequest, requestList, Request), - ASN1_EXP_SEQUENCE_OF_OPT(TBSRequest, requestExtensions, X509_EXTENSION, 2) + ASN1_EXP_OPT(TBSRequest, version, ASN1_INTEGER, 0), + ASN1_EXP_OPT(TBSRequest, requestorName, GENERAL_NAME, 1), + ASN1_SEQUENCE_OF(TBSRequest, requestList, Request), + ASN1_EXP_SEQUENCE_OF_OPT(TBSRequest, requestExtensions, X509_EXTENSION, 2) } ASN1_SEQUENCE_END(TBSRequest); ASN1_SEQUENCE(OCSPRequest) = { - ASN1_SIMPLE(OCSPRequest, tbsRequest, TBSRequest), - ASN1_EXP_OPT(OCSPRequest, optionalSignature, Signature, 0) + ASN1_SIMPLE(OCSPRequest, tbsRequest, TBSRequest), + ASN1_EXP_OPT(OCSPRequest, optionalSignature, Signature, 0) } ASN1_SEQUENCE_END(OCSPRequest); - /* Response templates */ ASN1_SEQUENCE(ResponseBytes) = { - ASN1_SIMPLE(ResponseBytes, responseType, ASN1_OBJECT), - ASN1_SIMPLE(ResponseBytes, response, ASN1_OCTET_STRING) + ASN1_SIMPLE(ResponseBytes, responseType, ASN1_OBJECT), + ASN1_SIMPLE(ResponseBytes, response, ASN1_OCTET_STRING) } ASN1_SEQUENCE_END(ResponseBytes); ASN1_SEQUENCE(OCSPResponse) = { - ASN1_SIMPLE(OCSPResponse, responseStatus, ASN1_ENUMERATED), - ASN1_EXP_OPT(OCSPResponse, responseBytes, ResponseBytes, 0) + ASN1_SIMPLE(OCSPResponse, responseStatus, ASN1_ENUMERATED), + ASN1_EXP_OPT(OCSPResponse, responseBytes, ResponseBytes, 0) } ASN1_SEQUENCE_END(OCSPResponse); ASN1_CHOICE(ResponderID) = { - ASN1_EXP(ResponderID, d.byName, X509_NAME, 1), - ASN1_IMP(ResponderID, d.byKey, ASN1_OCTET_STRING, 2) + ASN1_EXP(ResponderID, d.byName, X509_NAME, 1), + ASN1_IMP(ResponderID, d.byKey, ASN1_OCTET_STRING, 2) } ASN1_CHOICE_END(ResponderID); ASN1_SEQUENCE(RevokedInfo) = { - ASN1_SIMPLE(RevokedInfo, revocationTime, ASN1_GENERALIZEDTIME), - ASN1_EXP_OPT(RevokedInfo, revocationReason, ASN1_ENUMERATED, 0) + ASN1_SIMPLE(RevokedInfo, revocationTime, ASN1_GENERALIZEDTIME), + ASN1_EXP_OPT(RevokedInfo, revocationReason, ASN1_ENUMERATED, 0) } ASN1_SEQUENCE_END(RevokedInfo); ASN1_CHOICE(CertStatus) = { - ASN1_IMP(CertStatus, d.good, ASN1_NULL, 0), - ASN1_IMP(CertStatus, d.revoked, RevokedInfo, 1), - ASN1_IMP(CertStatus, d.unknown, ASN1_NULL, 2) + ASN1_IMP(CertStatus, d.good, ASN1_NULL, 0), + ASN1_IMP(CertStatus, d.revoked, RevokedInfo, 1), + ASN1_IMP(CertStatus, d.unknown, ASN1_NULL, 2) } ASN1_CHOICE_END(CertStatus); ASN1_SEQUENCE(SingleResponse) = { - ASN1_SIMPLE(SingleResponse, certID, CertID), - ASN1_SIMPLE(SingleResponse, certStatus, CertStatus), - ASN1_SIMPLE(SingleResponse, thisUpdate, ASN1_GENERALIZEDTIME), - ASN1_EXP_OPT(SingleResponse, nextUpdate, ASN1_GENERALIZEDTIME, 0), - ASN1_EXP_SEQUENCE_OF_OPT(SingleResponse, singleExtensions, X509_EXTENSION, 1) + ASN1_SIMPLE(SingleResponse, certID, CertID), + ASN1_SIMPLE(SingleResponse, certStatus, CertStatus), + ASN1_SIMPLE(SingleResponse, thisUpdate, ASN1_GENERALIZEDTIME), + ASN1_EXP_OPT(SingleResponse, nextUpdate, ASN1_GENERALIZEDTIME, 0), + ASN1_EXP_SEQUENCE_OF_OPT(SingleResponse, singleExtensions, X509_EXTENSION, 1) } ASN1_SEQUENCE_END(SingleResponse); ASN1_SEQUENCE(ResponseData) = { - ASN1_EXP_OPT(ResponseData, version, ASN1_INTEGER, 0), - ASN1_SIMPLE(ResponseData, responderID, ResponderID), - ASN1_SIMPLE(ResponseData, producedAt, ASN1_GENERALIZEDTIME), - ASN1_SEQUENCE_OF(ResponseData, responses, SingleResponse), - ASN1_EXP_SEQUENCE_OF_OPT(ResponseData, responseExtensions, X509_EXTENSION, 1) + ASN1_EXP_OPT(ResponseData, version, ASN1_INTEGER, 0), + ASN1_SIMPLE(ResponseData, responderID, ResponderID), + ASN1_SIMPLE(ResponseData, producedAt, ASN1_GENERALIZEDTIME), + ASN1_SEQUENCE_OF(ResponseData, responses, SingleResponse), + ASN1_EXP_SEQUENCE_OF_OPT(ResponseData, responseExtensions, X509_EXTENSION, 1) } ASN1_SEQUENCE_END(ResponseData); ASN1_SEQUENCE(BasicOCSPResponse) = { - ASN1_SIMPLE(BasicOCSPResponse, tbsResponseData, ResponseData), - ASN1_SIMPLE(BasicOCSPResponse, signatureAlgorithm, X509_ALGOR), - ASN1_SIMPLE(BasicOCSPResponse, signature, ASN1_BIT_STRING), - ASN1_EXP_SEQUENCE_OF_OPT(BasicOCSPResponse, certs, X509, 0) + ASN1_SIMPLE(BasicOCSPResponse, tbsResponseData, ResponseData), + ASN1_SIMPLE(BasicOCSPResponse, signatureAlgorithm, X509_ALGOR), + ASN1_SIMPLE(BasicOCSPResponse, signature, ASN1_BIT_STRING), + ASN1_EXP_SEQUENCE_OF_OPT(BasicOCSPResponse, certs, X509, 0) } ASN1_SEQUENCE_END(BasicOCSPResponse); - diff --git a/demos/b64.c b/demos/b64.c index efdd44457d..d8ed2a6a04 100644 --- a/demos/b64.c +++ b/demos/b64.c @@ -5,21 +5,21 @@ * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * 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. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -71,198 +71,185 @@ #undef BSIZE #undef PROG -#define SIZE (512) -#define BSIZE (8*1024) -#define PROG enc_main +#define SIZE (512) +#define BSIZE (8*1024) +#define PROG enc_main -int main(argc,argv) +int main(argc, argv) int argc; char **argv; - { - char *strbuf=NULL; - unsigned char *buff=NULL,*bufsize=NULL; - int bsize=BSIZE,verbose=0; - int ret=1,inl; - char *str=NULL; - char *hkey=NULL,*hiv=NULL; - int enc=1,printkey=0,i,base64=0; - int debug=0; - EVP_CIPHER *cipher=NULL,*c; - char *inf=NULL,*outf=NULL; - BIO *in=NULL,*out=NULL,*b64=NULL,*benc=NULL,*rbio=NULL,*wbio=NULL; +{ + char *strbuf = NULL; + unsigned char *buff = NULL, *bufsize = NULL; + int bsize = BSIZE, verbose = 0; + int ret = 1, inl; + char *str = NULL; + char *hkey = NULL, *hiv = NULL; + int enc = 1, printkey = 0, i, base64 = 0; + int debug = 0; + EVP_CIPHER *cipher = NULL, *c; + char *inf = NULL, *outf = NULL; + BIO *in = NULL, *out = NULL, *b64 = NULL, *benc = NULL, *rbio = + NULL, *wbio = NULL; #define PROG_NAME_SIZE 39 - - apps_startup(); - - if (bio_err == NULL) - if ((bio_err=BIO_new(BIO_s_file())) != NULL) - BIO_set_fp(bio_err,stderr,BIO_NOCLOSE); - - base64=1; - - argc--; - argv++; - while (argc >= 1) - { - if (strcmp(*argv,"-e") == 0) - enc=1; - if (strcmp(*argv,"-in") == 0) - { - if (--argc < 1) goto bad; - inf= *(++argv); - } - else if (strcmp(*argv,"-out") == 0) - { - if (--argc < 1) goto bad; - outf= *(++argv); - } - else if (strcmp(*argv,"-d") == 0) - enc=0; - else if (strcmp(*argv,"-v") == 0) - verbose=1; - else if (strcmp(*argv,"-debug") == 0) - debug=1; - else if (strcmp(*argv,"-bufsize") == 0) - { - if (--argc < 1) goto bad; - bufsize=(unsigned char *)*(++argv); - } - else - { - BIO_printf(bio_err,"unknown option '%s'\n",*argv); -bad: - BIO_printf(bio_err,"options are\n"); - BIO_printf(bio_err,"%-14s input file\n","-in <file>"); - BIO_printf(bio_err,"%-14s output file\n","-out <file>"); - BIO_printf(bio_err,"%-14s encode\n","-e"); - BIO_printf(bio_err,"%-14s decode\n","-d"); - BIO_printf(bio_err,"%-14s buffer size\n","-bufsize <n>"); - - goto end; - } - argc--; - argv++; - } - - if (bufsize != NULL) - { - int i; - unsigned long n; - - for (n=0; *bufsize; bufsize++) - { - i= *bufsize; - if ((i <= '9') && (i >= '0')) - n=n*10+i-' |