2011-02-05 22:14:47 +03:00
|
|
|
/* evp.h
|
|
|
|
*
|
2012-02-13 23:54:10 +04:00
|
|
|
* Copyright (C) 2012 Sawtooth Consulting Ltd.
|
2011-02-05 22:14:47 +03:00
|
|
|
*
|
|
|
|
* This file is part of CyaSSL.
|
|
|
|
*
|
|
|
|
* CyaSSL is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* CyaSSL is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* evp.h defines mini evp openssl compatibility layer
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef CYASSL_EVP_H_
|
|
|
|
#define CYASSL_EVP_H_
|
|
|
|
|
2012-01-17 03:11:37 +04:00
|
|
|
#include <cyassl/ctaocrypt/settings.h>
|
|
|
|
|
2011-02-05 22:14:47 +03:00
|
|
|
#ifdef YASSL_PREFIX
|
|
|
|
#include "prefix_evp.h"
|
|
|
|
#endif
|
|
|
|
|
2011-08-27 01:40:51 +04:00
|
|
|
#include <cyassl/openssl/md5.h>
|
|
|
|
#include <cyassl/openssl/sha.h>
|
2011-02-05 22:14:47 +03:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2011-08-27 01:40:51 +04:00
|
|
|
typedef char CYASSL_EVP_MD;
|
|
|
|
typedef char CYASSL_EVP_CIPHER;
|
2011-02-05 22:14:47 +03:00
|
|
|
|
2011-08-27 01:40:51 +04:00
|
|
|
CYASSL_API const CYASSL_EVP_MD* CyaSSL_EVP_md5(void);
|
|
|
|
CYASSL_API const CYASSL_EVP_MD* CyaSSL_EVP_sha1(void);
|
2011-02-05 22:14:47 +03:00
|
|
|
|
|
|
|
|
|
|
|
typedef union {
|
2011-08-27 01:40:51 +04:00
|
|
|
CYASSL_MD5_CTX md5;
|
|
|
|
CYASSL_SHA_CTX sha;
|
|
|
|
} CYASSL_Hasher;
|
2011-02-05 22:14:47 +03:00
|
|
|
|
|
|
|
|
2011-08-27 01:40:51 +04:00
|
|
|
typedef struct CYASSL_EVP_MD_CTX {
|
2011-02-05 22:14:47 +03:00
|
|
|
unsigned char macType; /* md5 or sha for now */
|
2011-08-27 01:40:51 +04:00
|
|
|
CYASSL_Hasher hash;
|
|
|
|
} CYASSL_EVP_MD_CTX;
|
|
|
|
|
|
|
|
|
|
|
|
CYASSL_API void CyaSSL_EVP_MD_CTX_init(CYASSL_EVP_MD_CTX* ctx);
|
|
|
|
CYASSL_API int CyaSSL_EVP_MD_CTX_cleanup(CYASSL_EVP_MD_CTX* ctx);
|
|
|
|
|
|
|
|
CYASSL_API int CyaSSL_EVP_DigestInit(CYASSL_EVP_MD_CTX* ctx,
|
|
|
|
const CYASSL_EVP_MD* type);
|
|
|
|
CYASSL_API int CyaSSL_EVP_DigestUpdate(CYASSL_EVP_MD_CTX* ctx, const void* data,
|
|
|
|
unsigned long sz);
|
|
|
|
CYASSL_API int CyaSSL_EVP_DigestFinal(CYASSL_EVP_MD_CTX* ctx, unsigned char* md,
|
|
|
|
unsigned int* s);
|
|
|
|
CYASSL_API int CyaSSL_EVP_DigestFinal_ex(CYASSL_EVP_MD_CTX* ctx,
|
|
|
|
unsigned char* md, unsigned int* s);
|
|
|
|
CYASSL_API int CyaSSL_EVP_BytesToKey(const CYASSL_EVP_CIPHER*,
|
|
|
|
const CYASSL_EVP_MD*, const unsigned char*,
|
|
|
|
const unsigned char*, int, int, unsigned char*,
|
|
|
|
unsigned char*);
|
|
|
|
|
|
|
|
typedef CYASSL_EVP_MD EVP_MD;
|
|
|
|
typedef CYASSL_EVP_CIPHER EVP_CIPHER;
|
|
|
|
typedef CYASSL_EVP_MD_CTX EVP_MD_CTX;
|
|
|
|
|
|
|
|
#define EVP_md5 CyaSSL_EVP_md5
|
|
|
|
#define EVP_sha1 CyaSSL_EVP_sha1
|
|
|
|
|
|
|
|
#define EVP_MD_CTX_init CyaSSL_EVP_MD_CTX_init
|
|
|
|
#define EVP_MD_CTX_cleanup CyaSSL_EVP_MD_CTX_cleanup
|
|
|
|
#define EVP_DigestInit CyaSSL_EVP_DigestInit
|
|
|
|
#define EVP_DigestUpdate CyaSSL_EVP_DigestUpdate
|
|
|
|
#define EVP_DigestFinal CyaSSL_EVP_DigestFinal
|
|
|
|
#define EVP_DigestFinal_ex CyaSSL_EVP_DigestFinal_ex
|
|
|
|
#define EVP_BytesToKey CyaSSL_EVP_BytesToKey
|
|
|
|
|
2011-02-05 22:14:47 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* CYASSL_EVP_H_ */
|