SKF Wrapper

This commit is contained in:
Zhi Guan
2016-05-29 00:22:33 +02:00
parent 0cf9126a7d
commit ee4384daeb
142 changed files with 9469 additions and 6750 deletions

View File

@@ -17,8 +17,8 @@ TEST=
APPS=
LIB=$(TOP)/libcrypto.a
LIBSRC=cbcmac.c cbcm_ameth.c cbcm_pmeth.c
LIBOBJ=cbcmac.o cbcm_ameth.o cbcm_pmeth.o
LIBSRC=cbcmac.c cbcmac_err.c cbcm_ameth.c cbcm_pmeth.c
LIBOBJ=cbcmac.o cbcmac_err.o cbcm_ameth.o cbcm_pmeth.o
SRC= $(LIBSRC)
@@ -76,38 +76,49 @@ clean:
# DO NOT DELETE THIS LINE -- make depend depends on it.
cm_ameth.o: ../../e_os.h ../../include/openssl/asn1.h
cm_ameth.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
cm_ameth.o: ../../include/openssl/cmac.h ../../include/openssl/crypto.h
cm_ameth.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
cm_ameth.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
cm_ameth.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
cm_ameth.o: ../../include/openssl/opensslconf.h
cm_ameth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
cm_ameth.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
cm_ameth.o: ../../include/openssl/symhacks.h ../asn1/asn1_locl.h ../cryptlib.h
cm_ameth.o: cm_ameth.c
cm_pmeth.o: ../../e_os.h ../../include/openssl/asn1.h
cm_pmeth.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
cm_pmeth.o: ../../include/openssl/cmac.h ../../include/openssl/conf.h
cm_pmeth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
cm_pmeth.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
cm_pmeth.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
cm_pmeth.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
cm_pmeth.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
cm_pmeth.o: ../../include/openssl/opensslconf.h
cm_pmeth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
cm_pmeth.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
cm_pmeth.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
cm_pmeth.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
cm_pmeth.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
cm_pmeth.o: ../cryptlib.h ../evp/evp_locl.h cm_pmeth.c
cmac.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
cmac.o: ../../include/openssl/buffer.h ../../include/openssl/cmac.h
cmac.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
cmac.o: ../../include/openssl/err.h ../../include/openssl/evp.h
cmac.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
cmac.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
cmac.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
cmac.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
cmac.o: ../../include/openssl/symhacks.h ../cryptlib.h cmac.c
cbcm_ameth.o: ../../e_os.h ../../include/openssl/asn1.h
cbcm_ameth.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
cbcm_ameth.o: ../../include/openssl/cbcmac.h ../../include/openssl/crypto.h
cbcm_ameth.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
cbcm_ameth.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
cbcm_ameth.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
cbcm_ameth.o: ../../include/openssl/opensslconf.h
cbcm_ameth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
cbcm_ameth.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
cbcm_ameth.o: ../../include/openssl/symhacks.h ../asn1/asn1_locl.h
cbcm_ameth.o: ../cryptlib.h cbcm_ameth.c
cbcm_pmeth.o: ../../e_os.h ../../include/openssl/asn1.h
cbcm_pmeth.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
cbcm_pmeth.o: ../../include/openssl/cbcmac.h ../../include/openssl/conf.h
cbcm_pmeth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
cbcm_pmeth.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
cbcm_pmeth.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
cbcm_pmeth.o: ../../include/openssl/evp.h ../../include/openssl/kdf.h
cbcm_pmeth.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
cbcm_pmeth.o: ../../include/openssl/objects.h
cbcm_pmeth.o: ../../include/openssl/opensslconf.h
cbcm_pmeth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
cbcm_pmeth.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
cbcm_pmeth.o: ../../include/openssl/sha.h ../../include/openssl/sm2.h
cbcm_pmeth.o: ../../include/openssl/sm3.h ../../include/openssl/stack.h
cbcm_pmeth.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
cbcm_pmeth.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
cbcm_pmeth.o: ../cryptlib.h ../evp/evp_locl.h cbcm_pmeth.c
cbcmac.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
cbcmac.o: ../../include/openssl/cbcmac.h ../../include/openssl/crypto.h
cbcmac.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
cbcmac.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
cbcmac.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
cbcmac.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
cbcmac.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
cbcmac.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
cbcmac.o: cbcmac.c
cbcmac_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
cbcmac_err.o: ../../include/openssl/cbcmac.h ../../include/openssl/crypto.h
cbcmac_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
cbcmac_err.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
cbcmac_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
cbcmac_err.o: ../../include/openssl/opensslconf.h
cbcmac_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
cbcmac_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
cbcmac_err.o: ../../include/openssl/symhacks.h cbcmac_err.c

View File

@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/cbcmac.h>
@@ -55,10 +56,12 @@ int CBCMAC_Init(CBCMAC_CTX *ctx, const void *key, size_t keylen,
{
int i, block_size;
if (!EVP_EncryptInit_ex(&ctx->cipher_ctx, cipher, key, NULL, eng)) {
if (!EVP_EncryptInit_ex(&ctx->cipher_ctx, cipher, eng, key, NULL)) {
CBCMACerr(CBCMAC_F_CBCMAC_INIT, CBCMAC_R_CIPHER_CTX_INIT_FAILED);
return 0;
}
if (EVP_CIPHER_CTX_mode(&ctx->cipher_ctx) != EVP_CIPH_ECB_MODE) {
CBCMACerr(CBCMAC_F_CBCMAC_INIT, CBCMAC_R_CIPHER_NOT_ECB_MODE);
return 0;
}
ctx->worklen = 0;
@@ -90,6 +93,7 @@ int CBCMAC_Update(CBCMAC_CTX *ctx, const void *data, size_t datalen)
}
if (!EVP_EncryptUpdate(&ctx->cipher_ctx, ctx->cbcstate, &len,
ctx->workspace, block_size)) {
CBCMACerr(CBCMAC_F_CBCMAC_UPDATE, ERR_R_EVP_LIB);
return 0;
}
}
@@ -127,7 +131,10 @@ int CBCMAC_Final(CBCMAC_CTX *ctx, unsigned char *out, size_t *outlen)
for (i = ctx->worklen; i < block_size; i++) {
ctx->workspace[i] = ctx->cbcstate[i];
}
EVP_EncryptUpdate(&(ctx->cipher_ctx), out, outlen, ctx->workspace, block_size);
if (!EVP_EncryptUpdate(&(ctx->cipher_ctx), out, outlen, ctx->workspace, block_size)) {
CBCMACerr(CBCMAC_F_CBCMAC_FINAL, ERR_R_EVP_LIB);
return 0;
}
} else {
for (i = 0; i < block_size; i++) {
@@ -135,7 +142,7 @@ int CBCMAC_Final(CBCMAC_CTX *ctx, unsigned char *out, size_t *outlen)
}
}
return 0;
return 1;
}
int CBCMAC_resume(CBCMAC_CTX *ctx)

View File

@@ -53,6 +53,7 @@
* 2. the message length should be multiple of block size
* 3. the implementation do not add padding
*/
#ifndef HEADER_CBCMAC_H
#define HEADER_CBCMAC_H
@@ -77,8 +78,25 @@ int CBCMAC_Update(CBCMAC_CTX *ctx, const void *data, size_t datalen);
int CBCMAC_Final(CBCMAC_CTX *ctx, unsigned char *out, size_t *outlen);
int CBCMAC_resume(CBCMAC_CTX *ctx);
/* BEGIN ERROR CODES */
/*
* The following lines are auto generated by the script mkerr.pl. Any changes
* made after this point may be overwritten when the script is next run.
*/
void ERR_load_CBCMAC_strings(void);
/* Error codes for the CBCMAC functions. */
/* Function codes. */
# define CBCMAC_F_CBCMAC_FINAL 100
# define CBCMAC_F_CBCMAC_INIT 101
# define CBCMAC_F_CBCMAC_UPDATE 102
/* Reason codes. */
# define CBCMAC_R_CIPHER_CTX_INIT_FAILED 100
# define CBCMAC_R_CIPHER_NOT_ECB_MODE 101
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,96 @@
/* crypto/cbcmac/cbcmac_err.c */
/* ====================================================================
* Copyright (c) 1999-2016 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).
*
*/
/*
* NOTE: this file was auto generated by the mkerr.pl script: any changes
* made to it will be overwritten when the script next updates this file,
* only reason strings will be preserved.
*/
#include <stdio.h>
#include <openssl/err.h>
#include <openssl/cbcmac.h>
/* BEGIN ERROR CODES */
#ifndef OPENSSL_NO_ERR
# define ERR_FUNC(func) ERR_PACK(ERR_LIB_CBCMAC,func,0)
# define ERR_REASON(reason) ERR_PACK(ERR_LIB_CBCMAC,0,reason)
static ERR_STRING_DATA CBCMAC_str_functs[] = {
{ERR_FUNC(CBCMAC_F_CBCMAC_FINAL), "CBCMAC_Final"},
{ERR_FUNC(CBCMAC_F_CBCMAC_INIT), "CBCMAC_Init"},
{ERR_FUNC(CBCMAC_F_CBCMAC_UPDATE), "CBCMAC_Update"},
{0, NULL}
};
static ERR_STRING_DATA CBCMAC_str_reasons[] = {
{ERR_REASON(CBCMAC_R_CIPHER_CTX_INIT_FAILED), "cipher ctx init failed"},
{ERR_REASON(CBCMAC_R_CIPHER_NOT_ECB_MODE), "cipher not ecb mode"},
{0, NULL}
};
#endif
void ERR_load_CBCMAC_strings(void)
{
#ifndef OPENSSL_NO_ERR
if (ERR_func_error_string(CBCMAC_str_functs[0].error) == NULL) {
ERR_load_strings(0, CBCMAC_str_functs);
ERR_load_strings(0, CBCMAC_str_reasons);
}
#endif
}