M7350v7_en_gpl
This commit is contained in:
194
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/aes/aes_cbc.c
Executable file
194
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/aes/aes_cbc.c
Executable file
@ -0,0 +1,194 @@
|
||||
/* crypto/aes/aes_cbc.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2002 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.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AES_DEBUG
|
||||
# ifndef NDEBUG
|
||||
# define NDEBUG
|
||||
# endif
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
#include <openssl/aes.h>
|
||||
#include "aes_locl.h"
|
||||
|
||||
//for debug sean
|
||||
#if 0
|
||||
static void debug_out(unsigned char *label, unsigned char *data, int data_length)
|
||||
{
|
||||
int i,j;
|
||||
int num_blocks;
|
||||
int block_remainder;
|
||||
|
||||
num_blocks = data_length >> 4;
|
||||
block_remainder = data_length & 15;
|
||||
|
||||
if (label)
|
||||
printf("%s\n", label);
|
||||
|
||||
if (data==NULL || data_length==0)
|
||||
return;
|
||||
|
||||
for (i=0; i<num_blocks; i++) {
|
||||
printf("\t");
|
||||
for (j=0; j<16; j++)
|
||||
printf("%02x ", data[j + (i<<4)]);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if (block_remainder > 0) {
|
||||
printf("\t");
|
||||
for (j=0; j<block_remainder; j++)
|
||||
printf("%02x ", data[j+(num_blocks<<4)]);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_FIPS_AES_ASM)
|
||||
void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const AES_KEY *key,
|
||||
unsigned char *ivec, const int enc) {
|
||||
|
||||
unsigned long n;
|
||||
unsigned long len = length;
|
||||
unsigned char tmp[AES_BLOCK_SIZE];
|
||||
const unsigned char *iv = ivec;
|
||||
|
||||
assert(in && out && key && ivec);
|
||||
assert((AES_ENCRYPT == enc)||(AES_DECRYPT == enc));
|
||||
|
||||
if (AES_ENCRYPT == enc) {
|
||||
//for debug sean
|
||||
#if 0
|
||||
printf("<<----------%s %d------------>>\n", __FUNCTION__, __LINE__);
|
||||
printf("<<----------rounds = %d------------>>\n", key->rounds);
|
||||
debug_out("<--in-->", in, length);
|
||||
debug_out("<--iv-->", ivec, AES_BLOCK_SIZE);
|
||||
#endif
|
||||
while (len >= AES_BLOCK_SIZE) {
|
||||
for(n=0; n < AES_BLOCK_SIZE; ++n)
|
||||
out[n] = in[n] ^ iv[n];
|
||||
AES_encrypt(out, out, key);
|
||||
iv = out;
|
||||
len -= AES_BLOCK_SIZE;
|
||||
in += AES_BLOCK_SIZE;
|
||||
out += AES_BLOCK_SIZE;
|
||||
}
|
||||
if (len) {
|
||||
for(n=0; n < len; ++n)
|
||||
out[n] = in[n] ^ iv[n];
|
||||
for(n=len; n < AES_BLOCK_SIZE; ++n)
|
||||
out[n] = iv[n];
|
||||
AES_encrypt(out, out, key);
|
||||
iv = out;
|
||||
}
|
||||
memcpy(ivec,iv,AES_BLOCK_SIZE);
|
||||
} else if (in != out) {
|
||||
//for debug sean
|
||||
#if 0
|
||||
printf("<<----------%s %d------------>>\n", __FUNCTION__, __LINE__);
|
||||
printf("<<----------rounds = %d------------>>\n", key->rounds);
|
||||
debug_out("<--in-->", in, length);
|
||||
debug_out("<--iv-->", ivec, AES_BLOCK_SIZE);
|
||||
#endif
|
||||
while (len >= AES_BLOCK_SIZE) {
|
||||
AES_decrypt(in, out, key);
|
||||
for(n=0; n < AES_BLOCK_SIZE; ++n)
|
||||
out[n] ^= iv[n];
|
||||
iv = in;
|
||||
len -= AES_BLOCK_SIZE;
|
||||
in += AES_BLOCK_SIZE;
|
||||
out += AES_BLOCK_SIZE;
|
||||
}
|
||||
if (len) {
|
||||
AES_decrypt(in,tmp,key);
|
||||
for(n=0; n < len; ++n)
|
||||
out[n] = tmp[n] ^ iv[n];
|
||||
iv = in;
|
||||
}
|
||||
memcpy(ivec,iv,AES_BLOCK_SIZE);
|
||||
} else {
|
||||
//for debug sean
|
||||
#if 0
|
||||
printf("<<----------%s %d------------>>\n", __FUNCTION__, __LINE__);
|
||||
printf("<<----------rounds = %d------------>>\n", key->rounds);
|
||||
debug_out("<--in-->", in, length);
|
||||
debug_out("<--iv-->", ivec, AES_BLOCK_SIZE);
|
||||
#endif
|
||||
while (len >= AES_BLOCK_SIZE) {
|
||||
memcpy(tmp, in, AES_BLOCK_SIZE);
|
||||
AES_decrypt(in, out, key);
|
||||
for(n=0; n < AES_BLOCK_SIZE; ++n)
|
||||
out[n] ^= ivec[n];
|
||||
memcpy(ivec, tmp, AES_BLOCK_SIZE);
|
||||
len -= AES_BLOCK_SIZE;
|
||||
in += AES_BLOCK_SIZE;
|
||||
out += AES_BLOCK_SIZE;
|
||||
}
|
||||
if (len) {
|
||||
memcpy(tmp, in, AES_BLOCK_SIZE);
|
||||
AES_decrypt(tmp, out, key);
|
||||
for(n=0; n < len; ++n)
|
||||
out[n] ^= ivec[n];
|
||||
for(n=len; n < AES_BLOCK_SIZE; ++n)
|
||||
out[n] = tmp[n];
|
||||
memcpy(ivec, tmp, AES_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
//for debug sean
|
||||
#if 0
|
||||
debug_out("<--in-->", in, length);
|
||||
debug_out("<--out-->", out-length, length);
|
||||
debug_out("<--iv-->", ivec, AES_BLOCK_SIZE);
|
||||
#endif
|
||||
}
|
||||
#endif
|
85
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/aes/aes_locl.h
Executable file
85
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/aes/aes_locl.h
Executable file
@ -0,0 +1,85 @@
|
||||
/* crypto/aes/aes.h -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2002 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.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_AES_LOCL_H
|
||||
#define HEADER_AES_LOCL_H
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
#ifdef OPENSSL_NO_AES
|
||||
#error AES is disabled.
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_M_IA64) && !defined(OPENSSL_SYS_WINCE)
|
||||
# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
|
||||
# define GETU32(p) SWAP(*((u32 *)(p)))
|
||||
# define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); }
|
||||
#else
|
||||
# define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
|
||||
# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); }
|
||||
#endif
|
||||
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned char u8;
|
||||
|
||||
#define MAXKC (256/32)
|
||||
#define MAXKB (256/8)
|
||||
#define MAXNR 14
|
||||
|
||||
/* This controls loop-unrolling in aes_core.c */
|
||||
#undef FULL_UNROLL
|
||||
|
||||
#endif /* !HEADER_AES_LOCL_H */
|
366
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/aes/fips.c
Executable file
366
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/aes/fips.c
Executable file
@ -0,0 +1,366 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2003 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openssl/fips.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/fips_rand.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/hmac.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include "fips_locl.h"
|
||||
|
||||
#ifdef OPENSSL_FIPS
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024
|
||||
#endif
|
||||
|
||||
static int fips_selftest_fail;
|
||||
static int fips_mode;
|
||||
static const void *fips_rand_check;
|
||||
|
||||
static void fips_set_mode(int onoff)
|
||||
{
|
||||
int owning_thread = fips_is_owning_thread();
|
||||
|
||||
if (fips_is_started())
|
||||
{
|
||||
if (!owning_thread) fips_w_lock();
|
||||
fips_mode = onoff;
|
||||
if (!owning_thread) fips_w_unlock();
|
||||
}
|
||||
}
|
||||
|
||||
static void fips_set_rand_check(const void *rand_check)
|
||||
{
|
||||
int owning_thread = fips_is_owning_thread();
|
||||
|
||||
if (fips_is_started())
|
||||
{
|
||||
if (!owning_thread) fips_w_lock();
|
||||
fips_rand_check = rand_check;
|
||||
if (!owning_thread) fips_w_unlock();
|
||||
}
|
||||
}
|
||||
|
||||
int FIPS_mode(void)
|
||||
{
|
||||
int ret = 0;
|
||||
int owning_thread = fips_is_owning_thread();
|
||||
|
||||
if (fips_is_started())
|
||||
{
|
||||
if (!owning_thread) fips_r_lock();
|
||||
ret = fips_mode;
|
||||
if (!owning_thread) fips_r_unlock();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
const void *FIPS_rand_check(void)
|
||||
{
|
||||
const void *ret = 0;
|
||||
int owning_thread = fips_is_owning_thread();
|
||||
|
||||
if (fips_is_started())
|
||||
{
|
||||
if (!owning_thread) fips_r_lock();
|
||||
ret = fips_rand_check;
|
||||
if (!owning_thread) fips_r_unlock();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int FIPS_selftest_failed(void)
|
||||
{
|
||||
int ret = 0;
|
||||
if (fips_is_started())
|
||||
{
|
||||
int owning_thread = fips_is_owning_thread();
|
||||
|
||||
if (!owning_thread) fips_r_lock();
|
||||
ret = fips_selftest_fail;
|
||||
if (!owning_thread) fips_r_unlock();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int FIPS_selftest()
|
||||
{
|
||||
ERR_load_crypto_strings();
|
||||
|
||||
return FIPS_selftest_sha1()
|
||||
&& FIPS_selftest_hmac()
|
||||
&& FIPS_selftest_aes()
|
||||
&& FIPS_selftest_des()
|
||||
&& FIPS_selftest_rsa()
|
||||
&& FIPS_selftest_dsa();
|
||||
}
|
||||
|
||||
#ifndef HMAC_EXT
|
||||
#define HMAC_EXT "sha1"
|
||||
#endif
|
||||
|
||||
static char key[]="etaonrishdlcupfm";
|
||||
|
||||
#ifdef OPENSSL_PIC
|
||||
int DSO_pathbyaddr(void *addr,char *path,int sz);
|
||||
|
||||
static int FIPS_check_dso()
|
||||
{
|
||||
unsigned char buf[1024];
|
||||
char path [512];
|
||||
unsigned char mdbuf[EVP_MAX_MD_SIZE];
|
||||
FILE *f;
|
||||
HMAC_CTX hmac;
|
||||
int len,n;
|
||||
|
||||
len = DSO_pathbyaddr(NULL,path,sizeof(path)-sizeof(HMAC_EXT));
|
||||
if (len<=0)
|
||||
{
|
||||
FIPSerr(FIPS_F_FIPS_CHECK_DSO,FIPS_R_NO_DSO_PATH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
f=fopen(path,"rb");
|
||||
if(!f)
|
||||
{
|
||||
FIPSerr(FIPS_F_FIPS_CHECK_EXE,FIPS_R_CANNOT_READ_EXE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
HMAC_Init(&hmac,key,strlen(key),EVP_sha1());
|
||||
while(!feof(f))
|
||||
{
|
||||
n=fread(buf,1,sizeof buf,f);
|
||||
if(ferror(f))
|
||||
{
|
||||
clearerr(f);
|
||||
fclose(f);
|
||||
FIPSerr(FIPS_F_FIPS_CHECK_EXE,FIPS_R_CANNOT_READ_EXE);
|
||||
return 0;
|
||||
}
|
||||
if (n) HMAC_Update(&hmac,buf,n);
|
||||
}
|
||||
fclose(f);
|
||||
HMAC_Final(&hmac,mdbuf,&n);
|
||||
HMAC_CTX_cleanup(&hmac);
|
||||
|
||||
path[len-1]='.';
|
||||
strcpy(path+len,HMAC_EXT);
|
||||
f=fopen(path,"rb");
|
||||
if(!f || fread(buf,1,20,f) != 20)
|
||||
{
|
||||
if (f) fclose(f);
|
||||
FIPSerr(FIPS_F_FIPS_CHECK_EXE,FIPS_R_CANNOT_READ_EXE_DIGEST);
|
||||
return 0;
|
||||
}
|
||||
fclose(f);
|
||||
if(memcmp(buf,mdbuf,20))
|
||||
{
|
||||
FIPSerr(FIPS_F_FIPS_CHECK_EXE,FIPS_R_EXE_DIGEST_DOES_NOT_MATCH);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
static int FIPS_check_exe(const char *path)
|
||||
{
|
||||
unsigned char buf[1024];
|
||||
char p2[PATH_MAX];
|
||||
unsigned int n;
|
||||
unsigned char mdbuf[EVP_MAX_MD_SIZE];
|
||||
FILE *f;
|
||||
HMAC_CTX hmac;
|
||||
const char *sha1_fmt="%s."HMAC_EXT;
|
||||
|
||||
f=fopen(path,"rb");
|
||||
#ifdef __CYGWIN32__
|
||||
/* cygwin scrupulously strips .exe extentions:-( as of now it's
|
||||
actually no point to attempt above fopen, but we keep the call
|
||||
just in case the behavior changes in the future... */
|
||||
if (!f)
|
||||
{
|
||||
sha1_fmt="%s.exe."HMAC_EXT;
|
||||
BIO_snprintf(p2,sizeof p2,"%s.exe",path);
|
||||
f=fopen(p2,"rb");
|
||||
}
|
||||
#endif
|
||||
if(!f)
|
||||
{
|
||||
FIPSerr(FIPS_F_FIPS_CHECK_EXE,FIPS_R_CANNOT_READ_EXE);
|
||||
return 0;
|
||||
}
|
||||
HMAC_Init(&hmac,key,strlen(key),EVP_sha1());
|
||||
while(!feof(f))
|
||||
{
|
||||
n=fread(buf,1,sizeof buf,f);
|
||||
if(ferror(f))
|
||||
{
|
||||
clearerr(f);
|
||||
fclose(f);
|
||||
FIPSerr(FIPS_F_FIPS_CHECK_EXE,FIPS_R_CANNOT_READ_EXE);
|
||||
return 0;
|
||||
}
|
||||
if (n) HMAC_Update(&hmac,buf,n);
|
||||
}
|
||||
fclose(f);
|
||||
HMAC_Final(&hmac,mdbuf,&n);
|
||||
HMAC_CTX_cleanup(&hmac);
|
||||
BIO_snprintf(p2,sizeof p2,sha1_fmt,path);
|
||||
f=fopen(p2,"rb");
|
||||
if(!f || fread(buf,1,20,f) != 20)
|
||||
{
|
||||
if (f) fclose(f);
|
||||
FIPSerr(FIPS_F_FIPS_CHECK_EXE,FIPS_R_CANNOT_READ_EXE_DIGEST);
|
||||
return 0;
|
||||
}
|
||||
fclose(f);
|
||||
if(memcmp(buf,mdbuf,20))
|
||||
{
|
||||
FIPSerr(FIPS_F_FIPS_CHECK_EXE,FIPS_R_EXE_DIGEST_DOES_NOT_MATCH);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int FIPS_mode_set(int onoff,const char *path)
|
||||
{
|
||||
int fips_set_owning_thread();
|
||||
int fips_clear_owning_thread();
|
||||
int ret = 0;
|
||||
|
||||
fips_w_lock();
|
||||
fips_set_started();
|
||||
fips_set_owning_thread();
|
||||
|
||||
if(onoff)
|
||||
{
|
||||
unsigned char buf[24];
|
||||
|
||||
fips_selftest_fail = 0;
|
||||
|
||||
/* Don't go into FIPS mode twice, just so we can do automagic
|
||||
seeding */
|
||||
if(FIPS_mode())
|
||||
{
|
||||
FIPSerr(FIPS_F_FIPS_MODE_SET,FIPS_R_FIPS_MODE_ALREADY_SET);
|
||||
fips_selftest_fail = 1;
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
|
||||
#ifdef OPENSSL_PIC
|
||||
if(!FIPS_check_dso())
|
||||
#else
|
||||
if(!FIPS_check_exe(path))
|
||||
#endif
|
||||
{
|
||||
fips_selftest_fail = 1;
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Perform RNG KAT before seeding */
|
||||
if (!FIPS_selftest_rng())
|
||||
{
|
||||
fips_selftest_fail = 1;
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* automagically seed PRNG if not already seeded */
|
||||
if(!FIPS_rand_seeded())
|
||||
{
|
||||
if(RAND_bytes(buf,sizeof buf) <= 0)
|
||||
{
|
||||
fips_selftest_fail = 1;
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
FIPS_set_prng_key(buf,buf+8);
|
||||
FIPS_rand_seed(buf+16,8);
|
||||
}
|
||||
|
||||
/* now switch into FIPS mode */
|
||||
fips_set_rand_check(FIPS_rand_method());
|
||||
RAND_set_rand_method(FIPS_rand_method());
|
||||
if(FIPS_selftest())
|
||||
fips_set_mode(1);
|
||||
else
|
||||
{
|
||||
fips_selftest_fail = 1;
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
ret = 1;
|
||||
goto end;
|
||||
}
|
||||
fips_set_mode(0);
|
||||
fips_selftest_fail = 0;
|
||||
ret = 1;
|
||||
end:
|
||||
fips_clear_owning_thread();
|
||||
fips_w_unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* here just to cause error codes to exist */
|
||||
static void dummy()
|
||||
{
|
||||
FIPSerr(FIPS_F_HASH_FINAL,FIPS_F_NON_FIPS_METHOD);
|
||||
FIPSerr(FIPS_F_HASH_FINAL,FIPS_R_FIPS_SELFTEST_FAILED);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
1269
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/aes/fips_aes_core.c
Executable file
1269
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/aes/fips_aes_core.c
Executable file
File diff suppressed because it is too large
Load Diff
85
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/aes/fips_aes_locl.h
Executable file
85
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/aes/fips_aes_locl.h
Executable file
@ -0,0 +1,85 @@
|
||||
/* crypto/aes/aes.h -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2002 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.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_AES_LOCL_H
|
||||
#define HEADER_AES_LOCL_H
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
#ifdef OPENSSL_NO_AES
|
||||
#error AES is disabled.
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_M_IA64) && !defined(OPENSSL_SYS_WINCE)
|
||||
# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
|
||||
# define GETU32(p) SWAP(*((u32 *)(p)))
|
||||
# define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); }
|
||||
#else
|
||||
# define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
|
||||
# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); }
|
||||
#endif
|
||||
|
||||
typedef unsigned long u32;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned char u8;
|
||||
|
||||
#define MAXKC (256/32)
|
||||
#define MAXKB (256/8)
|
||||
#define MAXNR 14
|
||||
|
||||
/* This controls loop-unrolling in aes_core.c */
|
||||
#undef FULL_UNROLL
|
||||
|
||||
#endif /* !HEADER_AES_LOCL_H */
|
70
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/aes/fips_locl.h
Executable file
70
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/aes/fips_locl.h
Executable file
@ -0,0 +1,70 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2003 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef OPENSSL_FIPS
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* These are trampolines implemented in crypto/cryptlib.c */
|
||||
void fips_w_lock(void);
|
||||
void fips_w_unlock(void);
|
||||
void fips_r_lock(void);
|
||||
void fips_r_unlock(void);
|
||||
int fips_is_started(void);
|
||||
void fips_set_started(void);
|
||||
int fips_is_owning_thread(void);
|
||||
int fips_set_owning_thread(void);
|
||||
int fips_clear_owning_thread(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
321
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_add.c
Executable file
321
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_add.c
Executable file
@ -0,0 +1,321 @@
|
||||
/* crypto/bn/bn_add.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
/*Begin: 17Aug2006, Chris */
|
||||
#include "ossl_typ.h"
|
||||
/*End: 17Aug2006, Chris */
|
||||
|
||||
/* r can == a or b */
|
||||
int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
|
||||
{
|
||||
const BIGNUM *tmp;
|
||||
int a_neg = a->neg, ret;
|
||||
|
||||
bn_check_top(a);
|
||||
bn_check_top(b);
|
||||
|
||||
/* a + b a+b
|
||||
* a + -b a-b
|
||||
* -a + b b-a
|
||||
* -a + -b -(a+b)
|
||||
*/
|
||||
if (a_neg ^ b->neg)
|
||||
{
|
||||
/* only one is negative */
|
||||
if (a_neg)
|
||||
{ tmp=a; a=b; b=tmp; }
|
||||
|
||||
/* we are now a - b */
|
||||
|
||||
if (BN_ucmp(a,b) < 0)
|
||||
{
|
||||
if (!BN_usub(r,b,a)) return(0);
|
||||
r->neg=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!BN_usub(r,a,b)) return(0);
|
||||
r->neg=0;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
ret = BN_uadd(r,a,b);
|
||||
r->neg = a_neg;
|
||||
bn_check_top(r);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* unsigned add of b to a */
|
||||
int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
|
||||
{
|
||||
int max,min,dif;
|
||||
BN_ULONG *ap,*bp,*rp,carry,t1,t2;
|
||||
const BIGNUM *tmp;
|
||||
|
||||
bn_check_top(a);
|
||||
bn_check_top(b);
|
||||
|
||||
if (a->top < b->top)
|
||||
{ tmp=a; a=b; b=tmp; }
|
||||
max = a->top;
|
||||
min = b->top;
|
||||
dif = max - min;
|
||||
|
||||
if (bn_wexpand(r,max+1) == NULL)
|
||||
return 0;
|
||||
|
||||
r->top=max;
|
||||
|
||||
|
||||
ap=a->d;
|
||||
bp=b->d;
|
||||
rp=r->d;
|
||||
|
||||
carry=bn_add_words(rp,ap,bp,min);
|
||||
rp+=min;
|
||||
ap+=min;
|
||||
bp+=min;
|
||||
|
||||
if (carry)
|
||||
{
|
||||
while (dif)
|
||||
{
|
||||
dif--;
|
||||
t1 = *(ap++);
|
||||
t2 = (t1+1) & BN_MASK2;
|
||||
*(rp++) = t2;
|
||||
if (t2)
|
||||
{
|
||||
carry=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (carry)
|
||||
{
|
||||
/* carry != 0 => dif == 0 */
|
||||
*rp = 1;
|
||||
r->top++;
|
||||
}
|
||||
}
|
||||
if (dif && rp != ap)
|
||||
while (dif--)
|
||||
/* copy remaining words if ap != rp */
|
||||
*(rp++) = *(ap++);
|
||||
r->neg = 0;
|
||||
bn_check_top(r);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* unsigned subtraction of b from a, a must be larger than b. */
|
||||
int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
|
||||
{
|
||||
int max,min,dif;
|
||||
register BN_ULONG t1,t2,*ap,*bp,*rp;
|
||||
int i,carry;
|
||||
#if defined(IRIX_CC_BUG) && !defined(LINT)
|
||||
int dummy;
|
||||
#endif
|
||||
|
||||
bn_check_top(a);
|
||||
bn_check_top(b);
|
||||
|
||||
max = a->top;
|
||||
min = b->top;
|
||||
dif = max - min;
|
||||
|
||||
if (dif < 0) /* hmm... should not be happening */
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BNerr(BN_F_BN_USUB,BN_R_ARG2_LT_ARG3);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (bn_wexpand(r,max) == NULL) return(0);
|
||||
|
||||
ap=a->d;
|
||||
bp=b->d;
|
||||
rp=r->d;
|
||||
|
||||
#if 1
|
||||
carry=0;
|
||||
for (i = min; i != 0; i--)
|
||||
{
|
||||
t1= *(ap++);
|
||||
t2= *(bp++);
|
||||
if (carry)
|
||||
{
|
||||
carry=(t1 <= t2);
|
||||
t1=(t1-t2-1)&BN_MASK2;
|
||||
}
|
||||
else
|
||||
{
|
||||
carry=(t1 < t2);
|
||||
t1=(t1-t2)&BN_MASK2;
|
||||
}
|
||||
#if defined(IRIX_CC_BUG) && !defined(LINT)
|
||||
dummy=t1;
|
||||
#endif
|
||||
*(rp++)=t1&BN_MASK2;
|
||||
}
|
||||
#else
|
||||
carry=bn_sub_words(rp,ap,bp,min);
|
||||
ap+=min;
|
||||
bp+=min;
|
||||
rp+=min;
|
||||
#endif
|
||||
if (carry) /* subtracted */
|
||||
{
|
||||
if (!dif)
|
||||
/* error: a < b */
|
||||
return 0;
|
||||
while (dif)
|
||||
{
|
||||
dif--;
|
||||
t1 = *(ap++);
|
||||
t2 = (t1-1)&BN_MASK2;
|
||||
*(rp++) = t2;
|
||||
if (t1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
memcpy(rp,ap,sizeof(*rp)*(max-i));
|
||||
#else
|
||||
if (rp != ap)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if (!dif--) break;
|
||||
rp[0]=ap[0];
|
||||
if (!dif--) break;
|
||||
rp[1]=ap[1];
|
||||
if (!dif--) break;
|
||||
rp[2]=ap[2];
|
||||
if (!dif--) break;
|
||||
rp[3]=ap[3];
|
||||
rp+=4;
|
||||
ap+=4;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
r->top=max;
|
||||
r->neg=0;
|
||||
bn_correct_top(r);
|
||||
return(1);
|
||||
}
|
||||
|
||||
int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
|
||||
{
|
||||
int max;
|
||||
int add=0,neg=0;
|
||||
const BIGNUM *tmp;
|
||||
|
||||
bn_check_top(a);
|
||||
bn_check_top(b);
|
||||
|
||||
/* a - b a-b
|
||||
* a - -b a+b
|
||||
* -a - b -(a+b)
|
||||
* -a - -b b-a
|
||||
*/
|
||||
if (a->neg)
|
||||
{
|
||||
if (b->neg)
|
||||
{ tmp=a; a=b; b=tmp; }
|
||||
else
|
||||
{ add=1; neg=1; }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (b->neg) { add=1; neg=0; }
|
||||
}
|
||||
|
||||
if (add)
|
||||
{
|
||||
if (!BN_uadd(r,a,b)) return(0);
|
||||
r->neg=neg;
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* We are actually doing a - b :-) */
|
||||
|
||||
max=(a->top > b->top)?a->top:b->top;
|
||||
if (bn_wexpand(r,max) == NULL) return(0);
|
||||
if (BN_ucmp(a,b) < 0)
|
||||
{
|
||||
if (!BN_usub(r,b,a)) return(0);
|
||||
r->neg=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!BN_usub(r,a,b)) return(0);
|
||||
r->neg=0;
|
||||
}
|
||||
bn_check_top(r);
|
||||
return(1);
|
||||
}
|
||||
|
860
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_asm.c
Executable file
860
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_asm.c
Executable file
@ -0,0 +1,860 @@
|
||||
/* crypto/bn/bn_asm.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef BN_DEBUG
|
||||
# undef NDEBUG /* avoid conflicting definitions */
|
||||
# define NDEBUG
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
#if defined(BN_LLONG) || defined(BN_UMULT_HIGH)
|
||||
|
||||
BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
|
||||
{
|
||||
BN_ULONG c1=0;
|
||||
|
||||
assert(num >= 0);
|
||||
if (num <= 0) return(c1);
|
||||
|
||||
while (num&~3)
|
||||
{
|
||||
mul_add(rp[0],ap[0],w,c1);
|
||||
mul_add(rp[1],ap[1],w,c1);
|
||||
mul_add(rp[2],ap[2],w,c1);
|
||||
mul_add(rp[3],ap[3],w,c1);
|
||||
ap+=4; rp+=4; num-=4;
|
||||
}
|
||||
if (num)
|
||||
{
|
||||
mul_add(rp[0],ap[0],w,c1); if (--num==0) return c1;
|
||||
mul_add(rp[1],ap[1],w,c1); if (--num==0) return c1;
|
||||
mul_add(rp[2],ap[2],w,c1); return c1;
|
||||
}
|
||||
|
||||
return(c1);
|
||||
}
|
||||
|
||||
BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
|
||||
{
|
||||
BN_ULONG c1=0;
|
||||
|
||||
assert(num >= 0);
|
||||
if (num <= 0) return(c1);
|
||||
|
||||
while (num&~3)
|
||||
{
|
||||
mul(rp[0],ap[0],w,c1);
|
||||
mul(rp[1],ap[1],w,c1);
|
||||
mul(rp[2],ap[2],w,c1);
|
||||
mul(rp[3],ap[3],w,c1);
|
||||
ap+=4; rp+=4; num-=4;
|
||||
}
|
||||
if (num)
|
||||
{
|
||||
mul(rp[0],ap[0],w,c1); if (--num == 0) return c1;
|
||||
mul(rp[1],ap[1],w,c1); if (--num == 0) return c1;
|
||||
mul(rp[2],ap[2],w,c1);
|
||||
}
|
||||
return(c1);
|
||||
}
|
||||
|
||||
void bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n)
|
||||
{
|
||||
assert(n >= 0);
|
||||
if (n <= 0) return;
|
||||
while (n&~3)
|
||||
{
|
||||
sqr(r[0],r[1],a[0]);
|
||||
sqr(r[2],r[3],a[1]);
|
||||
sqr(r[4],r[5],a[2]);
|
||||
sqr(r[6],r[7],a[3]);
|
||||
a+=4; r+=8; n-=4;
|
||||
}
|
||||
if (n)
|
||||
{
|
||||
sqr(r[0],r[1],a[0]); if (--n == 0) return;
|
||||
sqr(r[2],r[3],a[1]); if (--n == 0) return;
|
||||
sqr(r[4],r[5],a[2]);
|
||||
}
|
||||
}
|
||||
|
||||
#else /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
|
||||
|
||||
BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
|
||||
{
|
||||
BN_ULONG c=0;
|
||||
BN_ULONG bl,bh;
|
||||
|
||||
assert(num >= 0);
|
||||
if (num <= 0) return((BN_ULONG)0);
|
||||
|
||||
bl=LBITS(w);
|
||||
bh=HBITS(w);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
mul_add(rp[0],ap[0],bl,bh,c);
|
||||
if (--num == 0) break;
|
||||
mul_add(rp[1],ap[1],bl,bh,c);
|
||||
if (--num == 0) break;
|
||||
mul_add(rp[2],ap[2],bl,bh,c);
|
||||
if (--num == 0) break;
|
||||
mul_add(rp[3],ap[3],bl,bh,c);
|
||||
if (--num == 0) break;
|
||||
ap+=4;
|
||||
rp+=4;
|
||||
}
|
||||
return(c);
|
||||
}
|
||||
|
||||
BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
|
||||
{
|
||||
BN_ULONG carry=0;
|
||||
BN_ULONG bl,bh;
|
||||
|
||||
assert(num >= 0);
|
||||
if (num <= 0) return((BN_ULONG)0);
|
||||
|
||||
bl=LBITS(w);
|
||||
bh=HBITS(w);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
mul(rp[0],ap[0],bl,bh,carry);
|
||||
if (--num == 0) break;
|
||||
mul(rp[1],ap[1],bl,bh,carry);
|
||||
if (--num == 0) break;
|
||||
mul(rp[2],ap[2],bl,bh,carry);
|
||||
if (--num == 0) break;
|
||||
mul(rp[3],ap[3],bl,bh,carry);
|
||||
if (--num == 0) break;
|
||||
ap+=4;
|
||||
rp+=4;
|
||||
}
|
||||
return(carry);
|
||||
}
|
||||
|
||||
void bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n)
|
||||
{
|
||||
assert(n >= 0);
|
||||
if (n <= 0) return;
|
||||
for (;;)
|
||||
{
|
||||
sqr64(r[0],r[1],a[0]);
|
||||
if (--n == 0) break;
|
||||
|
||||
sqr64(r[2],r[3],a[1]);
|
||||
if (--n == 0) break;
|
||||
|
||||
sqr64(r[4],r[5],a[2]);
|
||||
if (--n == 0) break;
|
||||
|
||||
sqr64(r[6],r[7],a[3]);
|
||||
if (--n == 0) break;
|
||||
|
||||
a+=4;
|
||||
r+=8;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
|
||||
|
||||
#if defined(BN_LLONG) && defined(BN_DIV2W)
|
||||
|
||||
BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)
|
||||
{
|
||||
return((BN_ULONG)(((((BN_ULLONG)h)<<BN_BITS2)|l)/(BN_ULLONG)d));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* Divide h,l by d and return the result. */
|
||||
/* I need to test this some more :-( */
|
||||
BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)
|
||||
{
|
||||
BN_ULONG dh,dl,q,ret=0,th,tl,t;
|
||||
int i,count=2;
|
||||
|
||||
if (d == 0) return(BN_MASK2);
|
||||
|
||||
i=BN_num_bits_word(d);
|
||||
assert((i == BN_BITS2) || (h <= (BN_ULONG)1<<i));
|
||||
|
||||
i=BN_BITS2-i;
|
||||
if (h >= d) h-=d;
|
||||
|
||||
if (i)
|
||||
{
|
||||
d<<=i;
|
||||
h=(h<<i)|(l>>(BN_BITS2-i));
|
||||
l<<=i;
|
||||
}
|
||||
dh=(d&BN_MASK2h)>>BN_BITS4;
|
||||
dl=(d&BN_MASK2l);
|
||||
for (;;)
|
||||
{
|
||||
if ((h>>BN_BITS4) == dh)
|
||||
q=BN_MASK2l;
|
||||
else
|
||||
q=h/dh;
|
||||
|
||||
th=q*dh;
|
||||
tl=dl*q;
|
||||
for (;;)
|
||||
{
|
||||
t=h-th;
|
||||
if ((t&BN_MASK2h) ||
|
||||
((tl) <= (
|
||||
(t<<BN_BITS4)|
|
||||
((l&BN_MASK2h)>>BN_BITS4))))
|
||||
break;
|
||||
q--;
|
||||
th-=dh;
|
||||
tl-=dl;
|
||||
}
|
||||
t=(tl>>BN_BITS4);
|
||||
tl=(tl<<BN_BITS4)&BN_MASK2h;
|
||||
th+=t;
|
||||
|
||||
if (l < tl) th++;
|
||||
l-=tl;
|
||||
if (h < th)
|
||||
{
|
||||
h+=d;
|
||||
q--;
|
||||
}
|
||||
h-=th;
|
||||
|
||||
if (--count == 0) break;
|
||||
|
||||
ret=q<<BN_BITS4;
|
||||
h=((h<<BN_BITS4)|(l>>BN_BITS4))&BN_MASK2;
|
||||
l=(l&BN_MASK2l)<<BN_BITS4;
|
||||
}
|
||||
ret|=q;
|
||||
return(ret);
|
||||
}
|
||||
#endif /* !defined(BN_LLONG) && defined(BN_DIV2W) */
|
||||
|
||||
#ifdef BN_LLONG
|
||||
BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
|
||||
{
|
||||
BN_ULLONG ll=0;
|
||||
|
||||
assert(n >= 0);
|
||||
if (n <= 0) return((BN_ULONG)0);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
ll+=(BN_ULLONG)a[0]+b[0];
|
||||
r[0]=(BN_ULONG)ll&BN_MASK2;
|
||||
ll>>=BN_BITS2;
|
||||
if (--n <= 0) break;
|
||||
|
||||
ll+=(BN_ULLONG)a[1]+b[1];
|
||||
r[1]=(BN_ULONG)ll&BN_MASK2;
|
||||
ll>>=BN_BITS2;
|
||||
if (--n <= 0) break;
|
||||
|
||||
ll+=(BN_ULLONG)a[2]+b[2];
|
||||
r[2]=(BN_ULONG)ll&BN_MASK2;
|
||||
ll>>=BN_BITS2;
|
||||
if (--n <= 0) break;
|
||||
|
||||
ll+=(BN_ULLONG)a[3]+b[3];
|
||||
r[3]=(BN_ULONG)ll&BN_MASK2;
|
||||
ll>>=BN_BITS2;
|
||||
if (--n <= 0) break;
|
||||
|
||||
a+=4;
|
||||
b+=4;
|
||||
r+=4;
|
||||
}
|
||||
return((BN_ULONG)ll);
|
||||
}
|
||||
#else /* !BN_LLONG */
|
||||
BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
|
||||
{
|
||||
BN_ULONG c,l,t;
|
||||
|
||||
assert(n >= 0);
|
||||
if (n <= 0) return((BN_ULONG)0);
|
||||
|
||||
c=0;
|
||||
for (;;)
|
||||
{
|
||||
t=a[0];
|
||||
t=(t+c)&BN_MASK2;
|
||||
c=(t < c);
|
||||
l=(t+b[0])&BN_MASK2;
|
||||
c+=(l < t);
|
||||
r[0]=l;
|
||||
if (--n <= 0) break;
|
||||
|
||||
t=a[1];
|
||||
t=(t+c)&BN_MASK2;
|
||||
c=(t < c);
|
||||
l=(t+b[1])&BN_MASK2;
|
||||
c+=(l < t);
|
||||
r[1]=l;
|
||||
if (--n <= 0) break;
|
||||
|
||||
t=a[2];
|
||||
t=(t+c)&BN_MASK2;
|
||||
c=(t < c);
|
||||
l=(t+b[2])&BN_MASK2;
|
||||
c+=(l < t);
|
||||
r[2]=l;
|
||||
if (--n <= 0) break;
|
||||
|
||||
t=a[3];
|
||||
t=(t+c)&BN_MASK2;
|
||||
c=(t < c);
|
||||
l=(t+b[3])&BN_MASK2;
|
||||
c+=(l < t);
|
||||
r[3]=l;
|
||||
if (--n <= 0) break;
|
||||
|
||||
a+=4;
|
||||
b+=4;
|
||||
r+=4;
|
||||
}
|
||||
return((BN_ULONG)c);
|
||||
}
|
||||
#endif /* !BN_LLONG */
|
||||
|
||||
BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
|
||||
{
|
||||
BN_ULONG t1,t2;
|
||||
int c=0;
|
||||
|
||||
assert(n >= 0);
|
||||
if (n <= 0) return((BN_ULONG)0);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
t1=a[0]; t2=b[0];
|
||||
r[0]=(t1-t2-c)&BN_MASK2;
|
||||
if (t1 != t2) c=(t1 < t2);
|
||||
if (--n <= 0) break;
|
||||
|
||||
t1=a[1]; t2=b[1];
|
||||
r[1]=(t1-t2-c)&BN_MASK2;
|
||||
if (t1 != t2) c=(t1 < t2);
|
||||
if (--n <= 0) break;
|
||||
|
||||
t1=a[2]; t2=b[2];
|
||||
r[2]=(t1-t2-c)&BN_MASK2;
|
||||
if (t1 != t2) c=(t1 < t2);
|
||||
if (--n <= 0) break;
|
||||
|
||||
t1=a[3]; t2=b[3];
|
||||
r[3]=(t1-t2-c)&BN_MASK2;
|
||||
if (t1 != t2) c=(t1 < t2);
|
||||
if (--n <= 0) break;
|
||||
|
||||
a+=4;
|
||||
b+=4;
|
||||
r+=4;
|
||||
}
|
||||
return(c);
|
||||
}
|
||||
|
||||
#ifdef BN_MUL_COMBA
|
||||
|
||||
#undef bn_mul_comba8
|
||||
#undef bn_mul_comba4
|
||||
#undef bn_sqr_comba8
|
||||
#undef bn_sqr_comba4
|
||||
|
||||
/* mul_add_c(a,b,c0,c1,c2) -- c+=a*b for three word number c=(c2,c1,c0) */
|
||||
/* mul_add_c2(a,b,c0,c1,c2) -- c+=2*a*b for three word number c=(c2,c1,c0) */
|
||||
/* sqr_add_c(a,i,c0,c1,c2) -- c+=a[i]^2 for three word number c=(c2,c1,c0) */
|
||||
/* sqr_add_c2(a,i,c0,c1,c2) -- c+=2*a[i]*a[j] for three word number c=(c2,c1,c0) */
|
||||
|
||||
#ifdef BN_LLONG
|
||||
#define mul_add_c(a,b,c0,c1,c2) \
|
||||
t=(BN_ULLONG)a*b; \
|
||||
t1=(BN_ULONG)Lw(t); \
|
||||
t2=(BN_ULONG)Hw(t); \
|
||||
c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
|
||||
c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
|
||||
|
||||
#define mul_add_c2(a,b,c0,c1,c2) \
|
||||
t=(BN_ULLONG)a*b; \
|
||||
tt=(t+t)&BN_MASK; \
|
||||
if (tt < t) c2++; \
|
||||
t1=(BN_ULONG)Lw(tt); \
|
||||
t2=(BN_ULONG)Hw(tt); \
|
||||
c0=(c0+t1)&BN_MASK2; \
|
||||
if ((c0 < t1) && (((++t2)&BN_MASK2) == 0)) c2++; \
|
||||
c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
|
||||
|
||||
#define sqr_add_c(a,i,c0,c1,c2) \
|
||||
t=(BN_ULLONG)a[i]*a[i]; \
|
||||
t1=(BN_ULONG)Lw(t); \
|
||||
t2=(BN_ULONG)Hw(t); \
|
||||
c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
|
||||
c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
|
||||
|
||||
#define sqr_add_c2(a,i,j,c0,c1,c2) \
|
||||
mul_add_c2((a)[i],(a)[j],c0,c1,c2)
|
||||
|
||||
#elif defined(BN_UMULT_LOHI)
|
||||
|
||||
#define mul_add_c(a,b,c0,c1,c2) { \
|
||||
BN_ULONG ta=(a),tb=(b); \
|
||||
BN_UMULT_LOHI(t1,t2,ta,tb); \
|
||||
c0 += t1; t2 += (c0<t1)?1:0; \
|
||||
c1 += t2; c2 += (c1<t2)?1:0; \
|
||||
}
|
||||
|
||||
#define mul_add_c2(a,b,c0,c1,c2) { \
|
||||
BN_ULONG ta=(a),tb=(b),t0; \
|
||||
BN_UMULT_LOHI(t0,t1,ta,tb); \
|
||||
t2 = t1+t1; c2 += (t2<t1)?1:0; \
|
||||
t1 = t0+t0; t2 += (t1<t0)?1:0; \
|
||||
c0 += t1; t2 += (c0<t1)?1:0; \
|
||||
c1 += t2; c2 += (c1<t2)?1:0; \
|
||||
}
|
||||
|
||||
#define sqr_add_c(a,i,c0,c1,c2) { \
|
||||
BN_ULONG ta=(a)[i]; \
|
||||
BN_UMULT_LOHI(t1,t2,ta,ta); \
|
||||
c0 += t1; t2 += (c0<t1)?1:0; \
|
||||
c1 += t2; c2 += (c1<t2)?1:0; \
|
||||
}
|
||||
|
||||
#define sqr_add_c2(a,i,j,c0,c1,c2) \
|
||||
mul_add_c2((a)[i],(a)[j],c0,c1,c2)
|
||||
|
||||
#elif defined(BN_UMULT_HIGH)
|
||||
|
||||
#define mul_add_c(a,b,c0,c1,c2) { \
|
||||
BN_ULONG ta=(a),tb=(b); \
|
||||
t1 = ta * tb; \
|
||||
t2 = BN_UMULT_HIGH(ta,tb); \
|
||||
c0 += t1; t2 += (c0<t1)?1:0; \
|
||||
c1 += t2; c2 += (c1<t2)?1:0; \
|
||||
}
|
||||
|
||||
#define mul_add_c2(a,b,c0,c1,c2) { \
|
||||
BN_ULONG ta=(a),tb=(b),t0; \
|
||||
t1 = BN_UMULT_HIGH(ta,tb); \
|
||||
t0 = ta * tb; \
|
||||
t2 = t1+t1; c2 += (t2<t1)?1:0; \
|
||||
t1 = t0+t0; t2 += (t1<t0)?1:0; \
|
||||
c0 += t1; t2 += (c0<t1)?1:0; \
|
||||
c1 += t2; c2 += (c1<t2)?1:0; \
|
||||
}
|
||||
|
||||
#define sqr_add_c(a,i,c0,c1,c2) { \
|
||||
BN_ULONG ta=(a)[i]; \
|
||||
t1 = ta * ta; \
|
||||
t2 = BN_UMULT_HIGH(ta,ta); \
|
||||
c0 += t1; t2 += (c0<t1)?1:0; \
|
||||
c1 += t2; c2 += (c1<t2)?1:0; \
|
||||
}
|
||||
|
||||
#define sqr_add_c2(a,i,j,c0,c1,c2) \
|
||||
mul_add_c2((a)[i],(a)[j],c0,c1,c2)
|
||||
|
||||
#else /* !BN_LLONG */
|
||||
#define mul_add_c(a,b,c0,c1,c2) \
|
||||
t1=LBITS(a); t2=HBITS(a); \
|
||||
bl=LBITS(b); bh=HBITS(b); \
|
||||
mul64(t1,t2,bl,bh); \
|
||||
c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
|
||||
c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
|
||||
|
||||
#define mul_add_c2(a,b,c0,c1,c2) \
|
||||
t1=LBITS(a); t2=HBITS(a); \
|
||||
bl=LBITS(b); bh=HBITS(b); \
|
||||
mul64(t1,t2,bl,bh); \
|
||||
if (t2 & BN_TBIT) c2++; \
|
||||
t2=(t2+t2)&BN_MASK2; \
|
||||
if (t1 & BN_TBIT) t2++; \
|
||||
t1=(t1+t1)&BN_MASK2; \
|
||||
c0=(c0+t1)&BN_MASK2; \
|
||||
if ((c0 < t1) && (((++t2)&BN_MASK2) == 0)) c2++; \
|
||||
c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
|
||||
|
||||
#define sqr_add_c(a,i,c0,c1,c2) \
|
||||
sqr64(t1,t2,(a)[i]); \
|
||||
c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
|
||||
c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
|
||||
|
||||
#define sqr_add_c2(a,i,j,c0,c1,c2) \
|
||||
mul_add_c2((a)[i],(a)[j],c0,c1,c2)
|
||||
#endif /* !BN_LLONG */
|
||||
|
||||
void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
|
||||
{
|
||||
#ifdef BN_LLONG
|
||||
BN_ULLONG t;
|
||||
#else
|
||||
BN_ULONG bl,bh;
|
||||
#endif
|
||||
BN_ULONG t1,t2;
|
||||
BN_ULONG c1,c2,c3;
|
||||
|
||||
c1=0;
|
||||
c2=0;
|
||||
c3=0;
|
||||
mul_add_c(a[0],b[0],c1,c2,c3);
|
||||
r[0]=c1;
|
||||
c1=0;
|
||||
mul_add_c(a[0],b[1],c2,c3,c1);
|
||||
mul_add_c(a[1],b[0],c2,c3,c1);
|
||||
r[1]=c2;
|
||||
c2=0;
|
||||
mul_add_c(a[2],b[0],c3,c1,c2);
|
||||
mul_add_c(a[1],b[1],c3,c1,c2);
|
||||
mul_add_c(a[0],b[2],c3,c1,c2);
|
||||
r[2]=c3;
|
||||
c3=0;
|
||||
mul_add_c(a[0],b[3],c1,c2,c3);
|
||||
mul_add_c(a[1],b[2],c1,c2,c3);
|
||||
mul_add_c(a[2],b[1],c1,c2,c3);
|
||||
mul_add_c(a[3],b[0],c1,c2,c3);
|
||||
r[3]=c1;
|
||||
c1=0;
|
||||
mul_add_c(a[4],b[0],c2,c3,c1);
|
||||
mul_add_c(a[3],b[1],c2,c3,c1);
|
||||
mul_add_c(a[2],b[2],c2,c3,c1);
|
||||
mul_add_c(a[1],b[3],c2,c3,c1);
|
||||
mul_add_c(a[0],b[4],c2,c3,c1);
|
||||
r[4]=c2;
|
||||
c2=0;
|
||||
mul_add_c(a[0],b[5],c3,c1,c2);
|
||||
mul_add_c(a[1],b[4],c3,c1,c2);
|
||||
mul_add_c(a[2],b[3],c3,c1,c2);
|
||||
mul_add_c(a[3],b[2],c3,c1,c2);
|
||||
mul_add_c(a[4],b[1],c3,c1,c2);
|
||||
mul_add_c(a[5],b[0],c3,c1,c2);
|
||||
r[5]=c3;
|
||||
c3=0;
|
||||
mul_add_c(a[6],b[0],c1,c2,c3);
|
||||
mul_add_c(a[5],b[1],c1,c2,c3);
|
||||
mul_add_c(a[4],b[2],c1,c2,c3);
|
||||
mul_add_c(a[3],b[3],c1,c2,c3);
|
||||
mul_add_c(a[2],b[4],c1,c2,c3);
|
||||
mul_add_c(a[1],b[5],c1,c2,c3);
|
||||
mul_add_c(a[0],b[6],c1,c2,c3);
|
||||
r[6]=c1;
|
||||
c1=0;
|
||||
mul_add_c(a[0],b[7],c2,c3,c1);
|
||||
mul_add_c(a[1],b[6],c2,c3,c1);
|
||||
mul_add_c(a[2],b[5],c2,c3,c1);
|
||||
mul_add_c(a[3],b[4],c2,c3,c1);
|
||||
mul_add_c(a[4],b[3],c2,c3,c1);
|
||||
mul_add_c(a[5],b[2],c2,c3,c1);
|
||||
mul_add_c(a[6],b[1],c2,c3,c1);
|
||||
mul_add_c(a[7],b[0],c2,c3,c1);
|
||||
r[7]=c2;
|
||||
c2=0;
|
||||
mul_add_c(a[7],b[1],c3,c1,c2);
|
||||
mul_add_c(a[6],b[2],c3,c1,c2);
|
||||
mul_add_c(a[5],b[3],c3,c1,c2);
|
||||
mul_add_c(a[4],b[4],c3,c1,c2);
|
||||
mul_add_c(a[3],b[5],c3,c1,c2);
|
||||
mul_add_c(a[2],b[6],c3,c1,c2);
|
||||
mul_add_c(a[1],b[7],c3,c1,c2);
|
||||
r[8]=c3;
|
||||
c3=0;
|
||||
mul_add_c(a[2],b[7],c1,c2,c3);
|
||||
mul_add_c(a[3],b[6],c1,c2,c3);
|
||||
mul_add_c(a[4],b[5],c1,c2,c3);
|
||||
mul_add_c(a[5],b[4],c1,c2,c3);
|
||||
mul_add_c(a[6],b[3],c1,c2,c3);
|
||||
mul_add_c(a[7],b[2],c1,c2,c3);
|
||||
r[9]=c1;
|
||||
c1=0;
|
||||
mul_add_c(a[7],b[3],c2,c3,c1);
|
||||
mul_add_c(a[6],b[4],c2,c3,c1);
|
||||
mul_add_c(a[5],b[5],c2,c3,c1);
|
||||
mul_add_c(a[4],b[6],c2,c3,c1);
|
||||
mul_add_c(a[3],b[7],c2,c3,c1);
|
||||
r[10]=c2;
|
||||
c2=0;
|
||||
mul_add_c(a[4],b[7],c3,c1,c2);
|
||||
mul_add_c(a[5],b[6],c3,c1,c2);
|
||||
mul_add_c(a[6],b[5],c3,c1,c2);
|
||||
mul_add_c(a[7],b[4],c3,c1,c2);
|
||||
r[11]=c3;
|
||||
c3=0;
|
||||
mul_add_c(a[7],b[5],c1,c2,c3);
|
||||
mul_add_c(a[6],b[6],c1,c2,c3);
|
||||
mul_add_c(a[5],b[7],c1,c2,c3);
|
||||
r[12]=c1;
|
||||
c1=0;
|
||||
mul_add_c(a[6],b[7],c2,c3,c1);
|
||||
mul_add_c(a[7],b[6],c2,c3,c1);
|
||||
r[13]=c2;
|
||||
c2=0;
|
||||
mul_add_c(a[7],b[7],c3,c1,c2);
|
||||
r[14]=c3;
|
||||
r[15]=c1;
|
||||
}
|
||||
|
||||
void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
|
||||
{
|
||||
#ifdef BN_LLONG
|
||||
BN_ULLONG t;
|
||||
#else
|
||||
BN_ULONG bl,bh;
|
||||
#endif
|
||||
BN_ULONG t1,t2;
|
||||
BN_ULONG c1,c2,c3;
|
||||
|
||||
c1=0;
|
||||
c2=0;
|
||||
c3=0;
|
||||
mul_add_c(a[0],b[0],c1,c2,c3);
|
||||
r[0]=c1;
|
||||
c1=0;
|
||||
mul_add_c(a[0],b[1],c2,c3,c1);
|
||||
mul_add_c(a[1],b[0],c2,c3,c1);
|
||||
r[1]=c2;
|
||||
c2=0;
|
||||
mul_add_c(a[2],b[0],c3,c1,c2);
|
||||
mul_add_c(a[1],b[1],c3,c1,c2);
|
||||
mul_add_c(a[0],b[2],c3,c1,c2);
|
||||
r[2]=c3;
|
||||
c3=0;
|
||||
mul_add_c(a[0],b[3],c1,c2,c3);
|
||||
mul_add_c(a[1],b[2],c1,c2,c3);
|
||||
mul_add_c(a[2],b[1],c1,c2,c3);
|
||||
mul_add_c(a[3],b[0],c1,c2,c3);
|
||||
r[3]=c1;
|
||||
c1=0;
|
||||
mul_add_c(a[3],b[1],c2,c3,c1);
|
||||
mul_add_c(a[2],b[2],c2,c3,c1);
|
||||
mul_add_c(a[1],b[3],c2,c3,c1);
|
||||
r[4]=c2;
|
||||
c2=0;
|
||||
mul_add_c(a[2],b[3],c3,c1,c2);
|
||||
mul_add_c(a[3],b[2],c3,c1,c2);
|
||||
r[5]=c3;
|
||||
c3=0;
|
||||
mul_add_c(a[3],b[3],c1,c2,c3);
|
||||
r[6]=c1;
|
||||
r[7]=c2;
|
||||
}
|
||||
|
||||
void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a)
|
||||
{
|
||||
#ifdef BN_LLONG
|
||||
BN_ULLONG t,tt;
|
||||
#else
|
||||
BN_ULONG bl,bh;
|
||||
#endif
|
||||
BN_ULONG t1,t2;
|
||||
BN_ULONG c1,c2,c3;
|
||||
|
||||
c1=0;
|
||||
c2=0;
|
||||
c3=0;
|
||||
sqr_add_c(a,0,c1,c2,c3);
|
||||
r[0]=c1;
|
||||
c1=0;
|
||||
sqr_add_c2(a,1,0,c2,c3,c1);
|
||||
r[1]=c2;
|
||||
c2=0;
|
||||
sqr_add_c(a,1,c3,c1,c2);
|
||||
sqr_add_c2(a,2,0,c3,c1,c2);
|
||||
r[2]=c3;
|
||||
c3=0;
|
||||
sqr_add_c2(a,3,0,c1,c2,c3);
|
||||
sqr_add_c2(a,2,1,c1,c2,c3);
|
||||
r[3]=c1;
|
||||
c1=0;
|
||||
sqr_add_c(a,2,c2,c3,c1);
|
||||
sqr_add_c2(a,3,1,c2,c3,c1);
|
||||
sqr_add_c2(a,4,0,c2,c3,c1);
|
||||
r[4]=c2;
|
||||
c2=0;
|
||||
sqr_add_c2(a,5,0,c3,c1,c2);
|
||||
sqr_add_c2(a,4,1,c3,c1,c2);
|
||||
sqr_add_c2(a,3,2,c3,c1,c2);
|
||||
r[5]=c3;
|
||||
c3=0;
|
||||
sqr_add_c(a,3,c1,c2,c3);
|
||||
sqr_add_c2(a,4,2,c1,c2,c3);
|
||||
sqr_add_c2(a,5,1,c1,c2,c3);
|
||||
sqr_add_c2(a,6,0,c1,c2,c3);
|
||||
r[6]=c1;
|
||||
c1=0;
|
||||
sqr_add_c2(a,7,0,c2,c3,c1);
|
||||
sqr_add_c2(a,6,1,c2,c3,c1);
|
||||
sqr_add_c2(a,5,2,c2,c3,c1);
|
||||
sqr_add_c2(a,4,3,c2,c3,c1);
|
||||
r[7]=c2;
|
||||
c2=0;
|
||||
sqr_add_c(a,4,c3,c1,c2);
|
||||
sqr_add_c2(a,5,3,c3,c1,c2);
|
||||
sqr_add_c2(a,6,2,c3,c1,c2);
|
||||
sqr_add_c2(a,7,1,c3,c1,c2);
|
||||
r[8]=c3;
|
||||
c3=0;
|
||||
sqr_add_c2(a,7,2,c1,c2,c3);
|
||||
sqr_add_c2(a,6,3,c1,c2,c3);
|
||||
sqr_add_c2(a,5,4,c1,c2,c3);
|
||||
r[9]=c1;
|
||||
c1=0;
|
||||
sqr_add_c(a,5,c2,c3,c1);
|
||||
sqr_add_c2(a,6,4,c2,c3,c1);
|
||||
sqr_add_c2(a,7,3,c2,c3,c1);
|
||||
r[10]=c2;
|
||||
c2=0;
|
||||
sqr_add_c2(a,7,4,c3,c1,c2);
|
||||
sqr_add_c2(a,6,5,c3,c1,c2);
|
||||
r[11]=c3;
|
||||
c3=0;
|
||||
sqr_add_c(a,6,c1,c2,c3);
|
||||
sqr_add_c2(a,7,5,c1,c2,c3);
|
||||
r[12]=c1;
|
||||
c1=0;
|
||||
sqr_add_c2(a,7,6,c2,c3,c1);
|
||||
r[13]=c2;
|
||||
c2=0;
|
||||
sqr_add_c(a,7,c3,c1,c2);
|
||||
r[14]=c3;
|
||||
r[15]=c1;
|
||||
}
|
||||
|
||||
void bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a)
|
||||
{
|
||||
#ifdef BN_LLONG
|
||||
BN_ULLONG t,tt;
|
||||
#else
|
||||
BN_ULONG bl,bh;
|
||||
#endif
|
||||
BN_ULONG t1,t2;
|
||||
BN_ULONG c1,c2,c3;
|
||||
|
||||
c1=0;
|
||||
c2=0;
|
||||
c3=0;
|
||||
sqr_add_c(a,0,c1,c2,c3);
|
||||
r[0]=c1;
|
||||
c1=0;
|
||||
sqr_add_c2(a,1,0,c2,c3,c1);
|
||||
r[1]=c2;
|
||||
c2=0;
|
||||
sqr_add_c(a,1,c3,c1,c2);
|
||||
sqr_add_c2(a,2,0,c3,c1,c2);
|
||||
r[2]=c3;
|
||||
c3=0;
|
||||
sqr_add_c2(a,3,0,c1,c2,c3);
|
||||
sqr_add_c2(a,2,1,c1,c2,c3);
|
||||
r[3]=c1;
|
||||
c1=0;
|
||||
sqr_add_c(a,2,c2,c3,c1);
|
||||
sqr_add_c2(a,3,1,c2,c3,c1);
|
||||
r[4]=c2;
|
||||
c2=0;
|
||||
sqr_add_c2(a,3,2,c3,c1,c2);
|
||||
r[5]=c3;
|
||||
c3=0;
|
||||
sqr_add_c(a,3,c1,c2,c3);
|
||||
r[6]=c1;
|
||||
r[7]=c2;
|
||||
}
|
||||
#else /* !BN_MUL_COMBA */
|
||||
|
||||
/* hmm... is it faster just to do a multiply? */
|
||||
#undef bn_sqr_comba4
|
||||
void bn_sqr_comba4(BN_ULONG *r, BN_ULONG *a)
|
||||
{
|
||||
BN_ULONG t[8];
|
||||
bn_sqr_normal(r,a,4,t);
|
||||
}
|
||||
|
||||
#undef bn_sqr_comba8
|
||||
void bn_sqr_comba8(BN_ULONG *r, BN_ULONG *a)
|
||||
{
|
||||
BN_ULONG t[16];
|
||||
bn_sqr_normal(r,a,8,t);
|
||||
}
|
||||
|
||||
void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
|
||||
{
|
||||
r[4]=bn_mul_words( &(r[0]),a,4,b[0]);
|
||||
r[5]=bn_mul_add_words(&(r[1]),a,4,b[1]);
|
||||
r[6]=bn_mul_add_words(&(r[2]),a,4,b[2]);
|
||||
r[7]=bn_mul_add_words(&(r[3]),a,4,b[3]);
|
||||
}
|
||||
|
||||
void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
|
||||
{
|
||||
r[ 8]=bn_mul_words( &(r[0]),a,8,b[0]);
|
||||
r[ 9]=bn_mul_add_words(&(r[1]),a,8,b[1]);
|
||||
r[10]=bn_mul_add_words(&(r[2]),a,8,b[2]);
|
||||
r[11]=bn_mul_add_words(&(r[3]),a,8,b[3]);
|
||||
r[12]=bn_mul_add_words(&(r[4]),a,8,b[4]);
|
||||
r[13]=bn_mul_add_words(&(r[5]),a,8,b[5]);
|
||||
r[14]=bn_mul_add_words(&(r[6]),a,8,b[6]);
|
||||
r[15]=bn_mul_add_words(&(r[7]),a,8,b[7]);
|
||||
}
|
||||
|
||||
#endif /* !BN_MUL_COMBA */
|
407
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_const.c
Executable file
407
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_const.c
Executable file
@ -0,0 +1,407 @@
|
||||
/* crypto/bn/knownprimes.c */
|
||||
/* Insert boilerplate */
|
||||
|
||||
#include "bn.h"
|
||||
|
||||
/* "First Oakley Default Group" from RFC2409, section 6.1.
|
||||
*
|
||||
* The prime is: 2^768 - 2 ^704 - 1 + 2^64 * { [2^638 pi] + 149686 }
|
||||
*
|
||||
* RFC2409 specifies a generator of 2.
|
||||
* RFC2412 specifies a generator of of 22.
|
||||
*/
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BIGNUM *get_rfc2409_prime_768(BIGNUM *bn)
|
||||
{
|
||||
static const unsigned char RFC2409_PRIME_768[]={
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,0x0F,0xDA,0xA2,
|
||||
0x21,0x68,0xC2,0x34,0xC4,0xC6,0x62,0x8B,0x80,0xDC,0x1C,0xD1,
|
||||
0x29,0x02,0x4E,0x08,0x8A,0x67,0xCC,0x74,0x02,0x0B,0xBE,0xA6,
|
||||
0x3B,0x13,0x9B,0x22,0x51,0x4A,0x08,0x79,0x8E,0x34,0x04,0xDD,
|
||||
0xEF,0x95,0x19,0xB3,0xCD,0x3A,0x43,0x1B,0x30,0x2B,0x0A,0x6D,
|
||||
0xF2,0x5F,0x14,0x37,0x4F,0xE1,0x35,0x6D,0x6D,0x51,0xC2,0x45,
|
||||
0xE4,0x85,0xB5,0x76,0x62,0x5E,0x7E,0xC6,0xF4,0x4C,0x42,0xE9,
|
||||
0xA6,0x3A,0x36,0x20,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
};
|
||||
return BN_bin2bn(RFC2409_PRIME_768,sizeof(RFC2409_PRIME_768),bn);
|
||||
}
|
||||
|
||||
/* "Second Oakley Default Group" from RFC2409, section 6.2.
|
||||
*
|
||||
* The prime is: 2^1024 - 2^960 - 1 + 2^64 * { [2^894 pi] + 129093 }.
|
||||
*
|
||||
* RFC2409 specifies a generator of 2.
|
||||
* RFC2412 specifies a generator of 22.
|
||||
*/
|
||||
|
||||
BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn)
|
||||
{
|
||||
static const unsigned char RFC2409_PRIME_1024[]={
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,0x0F,0xDA,0xA2,
|
||||
0x21,0x68,0xC2,0x34,0xC4,0xC6,0x62,0x8B,0x80,0xDC,0x1C,0xD1,
|
||||
0x29,0x02,0x4E,0x08,0x8A,0x67,0xCC,0x74,0x02,0x0B,0xBE,0xA6,
|
||||
0x3B,0x13,0x9B,0x22,0x51,0x4A,0x08,0x79,0x8E,0x34,0x04,0xDD,
|
||||
0xEF,0x95,0x19,0xB3,0xCD,0x3A,0x43,0x1B,0x30,0x2B,0x0A,0x6D,
|
||||
0xF2,0x5F,0x14,0x37,0x4F,0xE1,0x35,0x6D,0x6D,0x51,0xC2,0x45,
|
||||
0xE4,0x85,0xB5,0x76,0x62,0x5E,0x7E,0xC6,0xF4,0x4C,0x42,0xE9,
|
||||
0xA6,0x37,0xED,0x6B,0x0B,0xFF,0x5C,0xB6,0xF4,0x06,0xB7,0xED,
|
||||
0xEE,0x38,0x6B,0xFB,0x5A,0x89,0x9F,0xA5,0xAE,0x9F,0x24,0x11,
|
||||
0x7C,0x4B,0x1F,0xE6,0x49,0x28,0x66,0x51,0xEC,0xE6,0x53,0x81,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
};
|
||||
return BN_bin2bn(RFC2409_PRIME_1024,sizeof(RFC2409_PRIME_1024),bn);
|
||||
}
|
||||
|
||||
/* "1536-bit MODP Group" from RFC3526, Section 2.
|
||||
*
|
||||
* The prime is: 2^1536 - 2^1472 - 1 + 2^64 * { [2^1406 pi] + 741804 }
|
||||
*
|
||||
* RFC3526 specifies a generator of 2.
|
||||
* RFC2312 specifies a generator of 22.
|
||||
*/
|
||||
|
||||
BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn)
|
||||
{
|
||||
static const unsigned char RFC3526_PRIME_1536[]={
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,0x0F,0xDA,0xA2,
|
||||
0x21,0x68,0xC2,0x34,0xC4,0xC6,0x62,0x8B,0x80,0xDC,0x1C,0xD1,
|
||||
0x29,0x02,0x4E,0x08,0x8A,0x67,0xCC,0x74,0x02,0x0B,0xBE,0xA6,
|
||||
0x3B,0x13,0x9B,0x22,0x51,0x4A,0x08,0x79,0x8E,0x34,0x04,0xDD,
|
||||
0xEF,0x95,0x19,0xB3,0xCD,0x3A,0x43,0x1B,0x30,0x2B,0x0A,0x6D,
|
||||
0xF2,0x5F,0x14,0x37,0x4F,0xE1,0x35,0x6D,0x6D,0x51,0xC2,0x45,
|
||||
0xE4,0x85,0xB5,0x76,0x62,0x5E,0x7E,0xC6,0xF4,0x4C,0x42,0xE9,
|
||||
0xA6,0x37,0xED,0x6B,0x0B,0xFF,0x5C,0xB6,0xF4,0x06,0xB7,0xED,
|
||||
0xEE,0x38,0x6B,0xFB,0x5A,0x89,0x9F,0xA5,0xAE,0x9F,0x24,0x11,
|
||||
0x7C,0x4B,0x1F,0xE6,0x49,0x28,0x66,0x51,0xEC,0xE4,0x5B,0x3D,
|
||||
0xC2,0x00,0x7C,0xB8,0xA1,0x63,0xBF,0x05,0x98,0xDA,0x48,0x36,
|
||||
0x1C,0x55,0xD3,0x9A,0x69,0x16,0x3F,0xA8,0xFD,0x24,0xCF,0x5F,
|
||||
0x83,0x65,0x5D,0x23,0xDC,0xA3,0xAD,0x96,0x1C,0x62,0xF3,0x56,
|
||||
0x20,0x85,0x52,0xBB,0x9E,0xD5,0x29,0x07,0x70,0x96,0x96,0x6D,
|
||||
0x67,0x0C,0x35,0x4E,0x4A,0xBC,0x98,0x04,0xF1,0x74,0x6C,0x08,
|
||||
0xCA,0x23,0x73,0x27,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
};
|
||||
return BN_bin2bn(RFC3526_PRIME_1536,sizeof(RFC3526_PRIME_1536),bn);
|
||||
}
|
||||
|
||||
/* "2048-bit MODP Group" from RFC3526, Section 3.
|
||||
*
|
||||
* The prime is: 2^2048 - 2^1984 - 1 + 2^64 * { [2^1918 pi] + 124476 }
|
||||
*
|
||||
* RFC3526 specifies a generator of 2.
|
||||
*/
|
||||
|
||||
BIGNUM *get_rfc3526_prime_2048(BIGNUM *bn)
|
||||
{
|
||||
static const unsigned char RFC3526_PRIME_2048[]={
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,0x0F,0xDA,0xA2,
|
||||
0x21,0x68,0xC2,0x34,0xC4,0xC6,0x62,0x8B,0x80,0xDC,0x1C,0xD1,
|
||||
0x29,0x02,0x4E,0x08,0x8A,0x67,0xCC,0x74,0x02,0x0B,0xBE,0xA6,
|
||||
0x3B,0x13,0x9B,0x22,0x51,0x4A,0x08,0x79,0x8E,0x34,0x04,0xDD,
|
||||
0xEF,0x95,0x19,0xB3,0xCD,0x3A,0x43,0x1B,0x30,0x2B,0x0A,0x6D,
|
||||
0xF2,0x5F,0x14,0x37,0x4F,0xE1,0x35,0x6D,0x6D,0x51,0xC2,0x45,
|
||||
0xE4,0x85,0xB5,0x76,0x62,0x5E,0x7E,0xC6,0xF4,0x4C,0x42,0xE9,
|
||||
0xA6,0x37,0xED,0x6B,0x0B,0xFF,0x5C,0xB6,0xF4,0x06,0xB7,0xED,
|
||||
0xEE,0x38,0x6B,0xFB,0x5A,0x89,0x9F,0xA5,0xAE,0x9F,0x24,0x11,
|
||||
0x7C,0x4B,0x1F,0xE6,0x49,0x28,0x66,0x51,0xEC,0xE4,0x5B,0x3D,
|
||||
0xC2,0x00,0x7C,0xB8,0xA1,0x63,0xBF,0x05,0x98,0xDA,0x48,0x36,
|
||||
0x1C,0x55,0xD3,0x9A,0x69,0x16,0x3F,0xA8,0xFD,0x24,0xCF,0x5F,
|
||||
0x83,0x65,0x5D,0x23,0xDC,0xA3,0xAD,0x96,0x1C,0x62,0xF3,0x56,
|
||||
0x20,0x85,0x52,0xBB,0x9E,0xD5,0x29,0x07,0x70,0x96,0x96,0x6D,
|
||||
0x67,0x0C,0x35,0x4E,0x4A,0xBC,0x98,0x04,0xF1,0x74,0x6C,0x08,
|
||||
0xCA,0x18,0x21,0x7C,0x32,0x90,0x5E,0x46,0x2E,0x36,0xCE,0x3B,
|
||||
0xE3,0x9E,0x77,0x2C,0x18,0x0E,0x86,0x03,0x9B,0x27,0x83,0xA2,
|
||||
0xEC,0x07,0xA2,0x8F,0xB5,0xC5,0x5D,0xF0,0x6F,0x4C,0x52,0xC9,
|
||||
0xDE,0x2B,0xCB,0xF6,0x95,0x58,0x17,0x18,0x39,0x95,0x49,0x7C,
|
||||
0xEA,0x95,0x6A,0xE5,0x15,0xD2,0x26,0x18,0x98,0xFA,0x05,0x10,
|
||||
0x15,0x72,0x8E,0x5A,0x8A,0xAC,0xAA,0x68,0xFF,0xFF,0xFF,0xFF,
|
||||
0xFF,0xFF,0xFF,0xFF,
|
||||
};
|
||||
return BN_bin2bn(RFC3526_PRIME_2048,sizeof(RFC3526_PRIME_2048),bn);
|
||||
}
|
||||
|
||||
/* "3072-bit MODP Group" from RFC3526, Section 4.
|
||||
*
|
||||
* The prime is: 2^3072 - 2^3008 - 1 + 2^64 * { [2^2942 pi] + 1690314 }
|
||||
*
|
||||
* RFC3526 specifies a generator of 2.
|
||||
*/
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
BIGNUM *get_rfc3526_prime_3072(BIGNUM *bn)
|
||||
{
|
||||
static const unsigned char RFC3526_PRIME_3072[]={
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,0x0F,0xDA,0xA2,
|
||||
0x21,0x68,0xC2,0x34,0xC4,0xC6,0x62,0x8B,0x80,0xDC,0x1C,0xD1,
|
||||
0x29,0x02,0x4E,0x08,0x8A,0x67,0xCC,0x74,0x02,0x0B,0xBE,0xA6,
|
||||
0x3B,0x13,0x9B,0x22,0x51,0x4A,0x08,0x79,0x8E,0x34,0x04,0xDD,
|
||||
0xEF,0x95,0x19,0xB3,0xCD,0x3A,0x43,0x1B,0x30,0x2B,0x0A,0x6D,
|
||||
0xF2,0x5F,0x14,0x37,0x4F,0xE1,0x35,0x6D,0x6D,0x51,0xC2,0x45,
|
||||
0xE4,0x85,0xB5,0x76,0x62,0x5E,0x7E,0xC6,0xF4,0x4C,0x42,0xE9,
|
||||
0xA6,0x37,0xED,0x6B,0x0B,0xFF,0x5C,0xB6,0xF4,0x06,0xB7,0xED,
|
||||
0xEE,0x38,0x6B,0xFB,0x5A,0x89,0x9F,0xA5,0xAE,0x9F,0x24,0x11,
|
||||
0x7C,0x4B,0x1F,0xE6,0x49,0x28,0x66,0x51,0xEC,0xE4,0x5B,0x3D,
|
||||
0xC2,0x00,0x7C,0xB8,0xA1,0x63,0xBF,0x05,0x98,0xDA,0x48,0x36,
|
||||
0x1C,0x55,0xD3,0x9A,0x69,0x16,0x3F,0xA8,0xFD,0x24,0xCF,0x5F,
|
||||
0x83,0x65,0x5D,0x23,0xDC,0xA3,0xAD,0x96,0x1C,0x62,0xF3,0x56,
|
||||
0x20,0x85,0x52,0xBB,0x9E,0xD5,0x29,0x07,0x70,0x96,0x96,0x6D,
|
||||
0x67,0x0C,0x35,0x4E,0x4A,0xBC,0x98,0x04,0xF1,0x74,0x6C,0x08,
|
||||
0xCA,0x18,0x21,0x7C,0x32,0x90,0x5E,0x46,0x2E,0x36,0xCE,0x3B,
|
||||
0xE3,0x9E,0x77,0x2C,0x18,0x0E,0x86,0x03,0x9B,0x27,0x83,0xA2,
|
||||
0xEC,0x07,0xA2,0x8F,0xB5,0xC5,0x5D,0xF0,0x6F,0x4C,0x52,0xC9,
|
||||
0xDE,0x2B,0xCB,0xF6,0x95,0x58,0x17,0x18,0x39,0x95,0x49,0x7C,
|
||||
0xEA,0x95,0x6A,0xE5,0x15,0xD2,0x26,0x18,0x98,0xFA,0x05,0x10,
|
||||
0x15,0x72,0x8E,0x5A,0x8A,0xAA,0xC4,0x2D,0xAD,0x33,0x17,0x0D,
|
||||
0x04,0x50,0x7A,0x33,0xA8,0x55,0x21,0xAB,0xDF,0x1C,0xBA,0x64,
|
||||
0xEC,0xFB,0x85,0x04,0x58,0xDB,0xEF,0x0A,0x8A,0xEA,0x71,0x57,
|
||||
0x5D,0x06,0x0C,0x7D,0xB3,0x97,0x0F,0x85,0xA6,0xE1,0xE4,0xC7,
|
||||
0xAB,0xF5,0xAE,0x8C,0xDB,0x09,0x33,0xD7,0x1E,0x8C,0x94,0xE0,
|
||||
0x4A,0x25,0x61,0x9D,0xCE,0xE3,0xD2,0x26,0x1A,0xD2,0xEE,0x6B,
|
||||
0xF1,0x2F,0xFA,0x06,0xD9,0x8A,0x08,0x64,0xD8,0x76,0x02,0x73,
|
||||
0x3E,0xC8,0x6A,0x64,0x52,0x1F,0x2B,0x18,0x17,0x7B,0x20,0x0C,
|
||||
0xBB,0xE1,0x17,0x57,0x7A,0x61,0x5D,0x6C,0x77,0x09,0x88,0xC0,
|
||||
0xBA,0xD9,0x46,0xE2,0x08,0xE2,0x4F,0xA0,0x74,0xE5,0xAB,0x31,
|
||||
0x43,0xDB,0x5B,0xFC,0xE0,0xFD,0x10,0x8E,0x4B,0x82,0xD1,0x20,
|
||||
0xA9,0x3A,0xD2,0xCA,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
};
|
||||
return BN_bin2bn(RFC3526_PRIME_3072,sizeof(RFC3526_PRIME_3072),bn);
|
||||
}
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
/* "4096-bit MODP Group" from RFC3526, Section 5.
|
||||
*
|
||||
* The prime is: 2^4096 - 2^4032 - 1 + 2^64 * { [2^3966 pi] + 240904 }
|
||||
*
|
||||
* RFC3526 specifies a generator of 2.
|
||||
*/
|
||||
|
||||
BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn)
|
||||
{
|
||||
static const unsigned char RFC3526_PRIME_4096[]={
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,0x0F,0xDA,0xA2,
|
||||
0x21,0x68,0xC2,0x34,0xC4,0xC6,0x62,0x8B,0x80,0xDC,0x1C,0xD1,
|
||||
0x29,0x02,0x4E,0x08,0x8A,0x67,0xCC,0x74,0x02,0x0B,0xBE,0xA6,
|
||||
0x3B,0x13,0x9B,0x22,0x51,0x4A,0x08,0x79,0x8E,0x34,0x04,0xDD,
|
||||
0xEF,0x95,0x19,0xB3,0xCD,0x3A,0x43,0x1B,0x30,0x2B,0x0A,0x6D,
|
||||
0xF2,0x5F,0x14,0x37,0x4F,0xE1,0x35,0x6D,0x6D,0x51,0xC2,0x45,
|
||||
0xE4,0x85,0xB5,0x76,0x62,0x5E,0x7E,0xC6,0xF4,0x4C,0x42,0xE9,
|
||||
0xA6,0x37,0xED,0x6B,0x0B,0xFF,0x5C,0xB6,0xF4,0x06,0xB7,0xED,
|
||||
0xEE,0x38,0x6B,0xFB,0x5A,0x89,0x9F,0xA5,0xAE,0x9F,0x24,0x11,
|
||||
0x7C,0x4B,0x1F,0xE6,0x49,0x28,0x66,0x51,0xEC,0xE4,0x5B,0x3D,
|
||||
0xC2,0x00,0x7C,0xB8,0xA1,0x63,0xBF,0x05,0x98,0xDA,0x48,0x36,
|
||||
0x1C,0x55,0xD3,0x9A,0x69,0x16,0x3F,0xA8,0xFD,0x24,0xCF,0x5F,
|
||||
0x83,0x65,0x5D,0x23,0xDC,0xA3,0xAD,0x96,0x1C,0x62,0xF3,0x56,
|
||||
0x20,0x85,0x52,0xBB,0x9E,0xD5,0x29,0x07,0x70,0x96,0x96,0x6D,
|
||||
0x67,0x0C,0x35,0x4E,0x4A,0xBC,0x98,0x04,0xF1,0x74,0x6C,0x08,
|
||||
0xCA,0x18,0x21,0x7C,0x32,0x90,0x5E,0x46,0x2E,0x36,0xCE,0x3B,
|
||||
0xE3,0x9E,0x77,0x2C,0x18,0x0E,0x86,0x03,0x9B,0x27,0x83,0xA2,
|
||||
0xEC,0x07,0xA2,0x8F,0xB5,0xC5,0x5D,0xF0,0x6F,0x4C,0x52,0xC9,
|
||||
0xDE,0x2B,0xCB,0xF6,0x95,0x58,0x17,0x18,0x39,0x95,0x49,0x7C,
|
||||
0xEA,0x95,0x6A,0xE5,0x15,0xD2,0x26,0x18,0x98,0xFA,0x05,0x10,
|
||||
0x15,0x72,0x8E,0x5A,0x8A,0xAA,0xC4,0x2D,0xAD,0x33,0x17,0x0D,
|
||||
0x04,0x50,0x7A,0x33,0xA8,0x55,0x21,0xAB,0xDF,0x1C,0xBA,0x64,
|
||||
0xEC,0xFB,0x85,0x04,0x58,0xDB,0xEF,0x0A,0x8A,0xEA,0x71,0x57,
|
||||
0x5D,0x06,0x0C,0x7D,0xB3,0x97,0x0F,0x85,0xA6,0xE1,0xE4,0xC7,
|
||||
0xAB,0xF5,0xAE,0x8C,0xDB,0x09,0x33,0xD7,0x1E,0x8C,0x94,0xE0,
|
||||
0x4A,0x25,0x61,0x9D,0xCE,0xE3,0xD2,0x26,0x1A,0xD2,0xEE,0x6B,
|
||||
0xF1,0x2F,0xFA,0x06,0xD9,0x8A,0x08,0x64,0xD8,0x76,0x02,0x73,
|
||||
0x3E,0xC8,0x6A,0x64,0x52,0x1F,0x2B,0x18,0x17,0x7B,0x20,0x0C,
|
||||
0xBB,0xE1,0x17,0x57,0x7A,0x61,0x5D,0x6C,0x77,0x09,0x88,0xC0,
|
||||
0xBA,0xD9,0x46,0xE2,0x08,0xE2,0x4F,0xA0,0x74,0xE5,0xAB,0x31,
|
||||
0x43,0xDB,0x5B,0xFC,0xE0,0xFD,0x10,0x8E,0x4B,0x82,0xD1,0x20,
|
||||
0xA9,0x21,0x08,0x01,0x1A,0x72,0x3C,0x12,0xA7,0x87,0xE6,0xD7,
|
||||
0x88,0x71,0x9A,0x10,0xBD,0xBA,0x5B,0x26,0x99,0xC3,0x27,0x18,
|
||||
0x6A,0xF4,0xE2,0x3C,0x1A,0x94,0x68,0x34,0xB6,0x15,0x0B,0xDA,
|
||||
0x25,0x83,0xE9,0xCA,0x2A,0xD4,0x4C,0xE8,0xDB,0xBB,0xC2,0xDB,
|
||||
0x04,0xDE,0x8E,0xF9,0x2E,0x8E,0xFC,0x14,0x1F,0xBE,0xCA,0xA6,
|
||||
0x28,0x7C,0x59,0x47,0x4E,0x6B,0xC0,0x5D,0x99,0xB2,0x96,0x4F,
|
||||
0xA0,0x90,0xC3,0xA2,0x23,0x3B,0xA1,0x86,0x51,0x5B,0xE7,0xED,
|
||||
0x1F,0x61,0x29,0x70,0xCE,0xE2,0xD7,0xAF,0xB8,0x1B,0xDD,0x76,
|
||||
0x21,0x70,0x48,0x1C,0xD0,0x06,0x91,0x27,0xD5,0xB0,0x5A,0xA9,
|
||||
0x93,0xB4,0xEA,0x98,0x8D,0x8F,0xDD,0xC1,0x86,0xFF,0xB7,0xDC,
|
||||
0x90,0xA6,0xC0,0x8F,0x4D,0xF4,0x35,0xC9,0x34,0x06,0x31,0x99,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
};
|
||||
return BN_bin2bn(RFC3526_PRIME_4096,sizeof(RFC3526_PRIME_4096),bn);
|
||||
}
|
||||
|
||||
/* "6144-bit MODP Group" from RFC3526, Section 6.
|
||||
*
|
||||
* The prime is: 2^6144 - 2^6080 - 1 + 2^64 * { [2^6014 pi] + 929484 }
|
||||
*
|
||||
* RFC3526 specifies a generator of 2.
|
||||
*/
|
||||
|
||||
BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn)
|
||||
{
|
||||
static const unsigned char RFC3526_PRIME_6144[]={
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,0x0F,0xDA,0xA2,
|
||||
0x21,0x68,0xC2,0x34,0xC4,0xC6,0x62,0x8B,0x80,0xDC,0x1C,0xD1,
|
||||
0x29,0x02,0x4E,0x08,0x8A,0x67,0xCC,0x74,0x02,0x0B,0xBE,0xA6,
|
||||
0x3B,0x13,0x9B,0x22,0x51,0x4A,0x08,0x79,0x8E,0x34,0x04,0xDD,
|
||||
0xEF,0x95,0x19,0xB3,0xCD,0x3A,0x43,0x1B,0x30,0x2B,0x0A,0x6D,
|
||||
0xF2,0x5F,0x14,0x37,0x4F,0xE1,0x35,0x6D,0x6D,0x51,0xC2,0x45,
|
||||
0xE4,0x85,0xB5,0x76,0x62,0x5E,0x7E,0xC6,0xF4,0x4C,0x42,0xE9,
|
||||
0xA6,0x37,0xED,0x6B,0x0B,0xFF,0x5C,0xB6,0xF4,0x06,0xB7,0xED,
|
||||
0xEE,0x38,0x6B,0xFB,0x5A,0x89,0x9F,0xA5,0xAE,0x9F,0x24,0x11,
|
||||
0x7C,0x4B,0x1F,0xE6,0x49,0x28,0x66,0x51,0xEC,0xE4,0x5B,0x3D,
|
||||
0xC2,0x00,0x7C,0xB8,0xA1,0x63,0xBF,0x05,0x98,0xDA,0x48,0x36,
|
||||
0x1C,0x55,0xD3,0x9A,0x69,0x16,0x3F,0xA8,0xFD,0x24,0xCF,0x5F,
|
||||
0x83,0x65,0x5D,0x23,0xDC,0xA3,0xAD,0x96,0x1C,0x62,0xF3,0x56,
|
||||
0x20,0x85,0x52,0xBB,0x9E,0xD5,0x29,0x07,0x70,0x96,0x96,0x6D,
|
||||
0x67,0x0C,0x35,0x4E,0x4A,0xBC,0x98,0x04,0xF1,0x74,0x6C,0x08,
|
||||
0xCA,0x18,0x21,0x7C,0x32,0x90,0x5E,0x46,0x2E,0x36,0xCE,0x3B,
|
||||
0xE3,0x9E,0x77,0x2C,0x18,0x0E,0x86,0x03,0x9B,0x27,0x83,0xA2,
|
||||
0xEC,0x07,0xA2,0x8F,0xB5,0xC5,0x5D,0xF0,0x6F,0x4C,0x52,0xC9,
|
||||
0xDE,0x2B,0xCB,0xF6,0x95,0x58,0x17,0x18,0x39,0x95,0x49,0x7C,
|
||||
0xEA,0x95,0x6A,0xE5,0x15,0xD2,0x26,0x18,0x98,0xFA,0x05,0x10,
|
||||
0x15,0x72,0x8E,0x5A,0x8A,0xAA,0xC4,0x2D,0xAD,0x33,0x17,0x0D,
|
||||
0x04,0x50,0x7A,0x33,0xA8,0x55,0x21,0xAB,0xDF,0x1C,0xBA,0x64,
|
||||
0xEC,0xFB,0x85,0x04,0x58,0xDB,0xEF,0x0A,0x8A,0xEA,0x71,0x57,
|
||||
0x5D,0x06,0x0C,0x7D,0xB3,0x97,0x0F,0x85,0xA6,0xE1,0xE4,0xC7,
|
||||
0xAB,0xF5,0xAE,0x8C,0xDB,0x09,0x33,0xD7,0x1E,0x8C,0x94,0xE0,
|
||||
0x4A,0x25,0x61,0x9D,0xCE,0xE3,0xD2,0x26,0x1A,0xD2,0xEE,0x6B,
|
||||
0xF1,0x2F,0xFA,0x06,0xD9,0x8A,0x08,0x64,0xD8,0x76,0x02,0x73,
|
||||
0x3E,0xC8,0x6A,0x64,0x52,0x1F,0x2B,0x18,0x17,0x7B,0x20,0x0C,
|
||||
0xBB,0xE1,0x17,0x57,0x7A,0x61,0x5D,0x6C,0x77,0x09,0x88,0xC0,
|
||||
0xBA,0xD9,0x46,0xE2,0x08,0xE2,0x4F,0xA0,0x74,0xE5,0xAB,0x31,
|
||||
0x43,0xDB,0x5B,0xFC,0xE0,0xFD,0x10,0x8E,0x4B,0x82,0xD1,0x20,
|
||||
0xA9,0x21,0x08,0x01,0x1A,0x72,0x3C,0x12,0xA7,0x87,0xE6,0xD7,
|
||||
0x88,0x71,0x9A,0x10,0xBD,0xBA,0x5B,0x26,0x99,0xC3,0x27,0x18,
|
||||
0x6A,0xF4,0xE2,0x3C,0x1A,0x94,0x68,0x34,0xB6,0x15,0x0B,0xDA,
|
||||
0x25,0x83,0xE9,0xCA,0x2A,0xD4,0x4C,0xE8,0xDB,0xBB,0xC2,0xDB,
|
||||
0x04,0xDE,0x8E,0xF9,0x2E,0x8E,0xFC,0x14,0x1F,0xBE,0xCA,0xA6,
|
||||
0x28,0x7C,0x59,0x47,0x4E,0x6B,0xC0,0x5D,0x99,0xB2,0x96,0x4F,
|
||||
0xA0,0x90,0xC3,0xA2,0x23,0x3B,0xA1,0x86,0x51,0x5B,0xE7,0xED,
|
||||
0x1F,0x61,0x29,0x70,0xCE,0xE2,0xD7,0xAF,0xB8,0x1B,0xDD,0x76,
|
||||
0x21,0x70,0x48,0x1C,0xD0,0x06,0x91,0x27,0xD5,0xB0,0x5A,0xA9,
|
||||
0x93,0xB4,0xEA,0x98,0x8D,0x8F,0xDD,0xC1,0x86,0xFF,0xB7,0xDC,
|
||||
0x90,0xA6,0xC0,0x8F,0x4D,0xF4,0x35,0xC9,0x34,0x02,0x84,0x92,
|
||||
0x36,0xC3,0xFA,0xB4,0xD2,0x7C,0x70,0x26,0xC1,0xD4,0xDC,0xB2,
|
||||
0x60,0x26,0x46,0xDE,0xC9,0x75,0x1E,0x76,0x3D,0xBA,0x37,0xBD,
|
||||
0xF8,0xFF,0x94,0x06,0xAD,0x9E,0x53,0x0E,0xE5,0xDB,0x38,0x2F,
|
||||
0x41,0x30,0x01,0xAE,0xB0,0x6A,0x53,0xED,0x90,0x27,0xD8,0x31,
|
||||
0x17,0x97,0x27,0xB0,0x86,0x5A,0x89,0x18,0xDA,0x3E,0xDB,0xEB,
|
||||
0xCF,0x9B,0x14,0xED,0x44,0xCE,0x6C,0xBA,0xCE,0xD4,0xBB,0x1B,
|
||||
0xDB,0x7F,0x14,0x47,0xE6,0xCC,0x25,0x4B,0x33,0x20,0x51,0x51,
|
||||
0x2B,0xD7,0xAF,0x42,0x6F,0xB8,0xF4,0x01,0x37,0x8C,0xD2,0xBF,
|
||||
0x59,0x83,0xCA,0x01,0xC6,0x4B,0x92,0xEC,0xF0,0x32,0xEA,0x15,
|
||||
0xD1,0x72,0x1D,0x03,0xF4,0x82,0xD7,0xCE,0x6E,0x74,0xFE,0xF6,
|
||||
0xD5,0x5E,0x70,0x2F,0x46,0x98,0x0C,0x82,0xB5,0xA8,0x40,0x31,
|
||||
0x90,0x0B,0x1C,0x9E,0x59,0xE7,0xC9,0x7F,0xBE,0xC7,0xE8,0xF3,
|
||||
0x23,0xA9,0x7A,0x7E,0x36,0xCC,0x88,0xBE,0x0F,0x1D,0x45,0xB7,
|
||||
0xFF,0x58,0x5A,0xC5,0x4B,0xD4,0x07,0xB2,0x2B,0x41,0x54,0xAA,
|
||||
0xCC,0x8F,0x6D,0x7E,0xBF,0x48,0xE1,0xD8,0x14,0xCC,0x5E,0xD2,
|
||||
0x0F,0x80,0x37,0xE0,0xA7,0x97,0x15,0xEE,0xF2,0x9B,0xE3,0x28,
|
||||
0x06,0xA1,0xD5,0x8B,0xB7,0xC5,0xDA,0x76,0xF5,0x50,0xAA,0x3D,
|
||||
0x8A,0x1F,0xBF,0xF0,0xEB,0x19,0xCC,0xB1,0xA3,0x13,0xD5,0x5C,
|
||||
0xDA,0x56,0xC9,0xEC,0x2E,0xF2,0x96,0x32,0x38,0x7F,0xE8,0xD7,
|
||||
0x6E,0x3C,0x04,0x68,0x04,0x3E,0x8F,0x66,0x3F,0x48,0x60,0xEE,
|
||||
0x12,0xBF,0x2D,0x5B,0x0B,0x74,0x74,0xD6,0xE6,0x94,0xF9,0x1E,
|
||||
0x6D,0xCC,0x40,0x24,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
};
|
||||
return BN_bin2bn(RFC3526_PRIME_6144,sizeof(RFC3526_PRIME_6144),bn);
|
||||
}
|
||||
|
||||
/* "8192-bit MODP Group" from RFC3526, Section 7.
|
||||
*
|
||||
* The prime is: 2^8192 - 2^8128 - 1 + 2^64 * { [2^8062 pi] + 4743158 }
|
||||
*
|
||||
* RFC3526 specifies a generator of 2.
|
||||
*/
|
||||
|
||||
BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn)
|
||||
{
|
||||
static const unsigned char RFC3526_PRIME_8192[]={
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,0x0F,0xDA,0xA2,
|
||||
0x21,0x68,0xC2,0x34,0xC4,0xC6,0x62,0x8B,0x80,0xDC,0x1C,0xD1,
|
||||
0x29,0x02,0x4E,0x08,0x8A,0x67,0xCC,0x74,0x02,0x0B,0xBE,0xA6,
|
||||
0x3B,0x13,0x9B,0x22,0x51,0x4A,0x08,0x79,0x8E,0x34,0x04,0xDD,
|
||||
0xEF,0x95,0x19,0xB3,0xCD,0x3A,0x43,0x1B,0x30,0x2B,0x0A,0x6D,
|
||||
0xF2,0x5F,0x14,0x37,0x4F,0xE1,0x35,0x6D,0x6D,0x51,0xC2,0x45,
|
||||
0xE4,0x85,0xB5,0x76,0x62,0x5E,0x7E,0xC6,0xF4,0x4C,0x42,0xE9,
|
||||
0xA6,0x37,0xED,0x6B,0x0B,0xFF,0x5C,0xB6,0xF4,0x06,0xB7,0xED,
|
||||
0xEE,0x38,0x6B,0xFB,0x5A,0x89,0x9F,0xA5,0xAE,0x9F,0x24,0x11,
|
||||
0x7C,0x4B,0x1F,0xE6,0x49,0x28,0x66,0x51,0xEC,0xE4,0x5B,0x3D,
|
||||
0xC2,0x00,0x7C,0xB8,0xA1,0x63,0xBF,0x05,0x98,0xDA,0x48,0x36,
|
||||
0x1C,0x55,0xD3,0x9A,0x69,0x16,0x3F,0xA8,0xFD,0x24,0xCF,0x5F,
|
||||
0x83,0x65,0x5D,0x23,0xDC,0xA3,0xAD,0x96,0x1C,0x62,0xF3,0x56,
|
||||
0x20,0x85,0x52,0xBB,0x9E,0xD5,0x29,0x07,0x70,0x96,0x96,0x6D,
|
||||
0x67,0x0C,0x35,0x4E,0x4A,0xBC,0x98,0x04,0xF1,0x74,0x6C,0x08,
|
||||
0xCA,0x18,0x21,0x7C,0x32,0x90,0x5E,0x46,0x2E,0x36,0xCE,0x3B,
|
||||
0xE3,0x9E,0x77,0x2C,0x18,0x0E,0x86,0x03,0x9B,0x27,0x83,0xA2,
|
||||
0xEC,0x07,0xA2,0x8F,0xB5,0xC5,0x5D,0xF0,0x6F,0x4C,0x52,0xC9,
|
||||
0xDE,0x2B,0xCB,0xF6,0x95,0x58,0x17,0x18,0x39,0x95,0x49,0x7C,
|
||||
0xEA,0x95,0x6A,0xE5,0x15,0xD2,0x26,0x18,0x98,0xFA,0x05,0x10,
|
||||
0x15,0x72,0x8E,0x5A,0x8A,0xAA,0xC4,0x2D,0xAD,0x33,0x17,0x0D,
|
||||
0x04,0x50,0x7A,0x33,0xA8,0x55,0x21,0xAB,0xDF,0x1C,0xBA,0x64,
|
||||
0xEC,0xFB,0x85,0x04,0x58,0xDB,0xEF,0x0A,0x8A,0xEA,0x71,0x57,
|
||||
0x5D,0x06,0x0C,0x7D,0xB3,0x97,0x0F,0x85,0xA6,0xE1,0xE4,0xC7,
|
||||
0xAB,0xF5,0xAE,0x8C,0xDB,0x09,0x33,0xD7,0x1E,0x8C,0x94,0xE0,
|
||||
0x4A,0x25,0x61,0x9D,0xCE,0xE3,0xD2,0x26,0x1A,0xD2,0xEE,0x6B,
|
||||
0xF1,0x2F,0xFA,0x06,0xD9,0x8A,0x08,0x64,0xD8,0x76,0x02,0x73,
|
||||
0x3E,0xC8,0x6A,0x64,0x52,0x1F,0x2B,0x18,0x17,0x7B,0x20,0x0C,
|
||||
0xBB,0xE1,0x17,0x57,0x7A,0x61,0x5D,0x6C,0x77,0x09,0x88,0xC0,
|
||||
0xBA,0xD9,0x46,0xE2,0x08,0xE2,0x4F,0xA0,0x74,0xE5,0xAB,0x31,
|
||||
0x43,0xDB,0x5B,0xFC,0xE0,0xFD,0x10,0x8E,0x4B,0x82,0xD1,0x20,
|
||||
0xA9,0x21,0x08,0x01,0x1A,0x72,0x3C,0x12,0xA7,0x87,0xE6,0xD7,
|
||||
0x88,0x71,0x9A,0x10,0xBD,0xBA,0x5B,0x26,0x99,0xC3,0x27,0x18,
|
||||
0x6A,0xF4,0xE2,0x3C,0x1A,0x94,0x68,0x34,0xB6,0x15,0x0B,0xDA,
|
||||
0x25,0x83,0xE9,0xCA,0x2A,0xD4,0x4C,0xE8,0xDB,0xBB,0xC2,0xDB,
|
||||
0x04,0xDE,0x8E,0xF9,0x2E,0x8E,0xFC,0x14,0x1F,0xBE,0xCA,0xA6,
|
||||
0x28,0x7C,0x59,0x47,0x4E,0x6B,0xC0,0x5D,0x99,0xB2,0x96,0x4F,
|
||||
0xA0,0x90,0xC3,0xA2,0x23,0x3B,0xA1,0x86,0x51,0x5B,0xE7,0xED,
|
||||
0x1F,0x61,0x29,0x70,0xCE,0xE2,0xD7,0xAF,0xB8,0x1B,0xDD,0x76,
|
||||
0x21,0x70,0x48,0x1C,0xD0,0x06,0x91,0x27,0xD5,0xB0,0x5A,0xA9,
|
||||
0x93,0xB4,0xEA,0x98,0x8D,0x8F,0xDD,0xC1,0x86,0xFF,0xB7,0xDC,
|
||||
0x90,0xA6,0xC0,0x8F,0x4D,0xF4,0x35,0xC9,0x34,0x02,0x84,0x92,
|
||||
0x36,0xC3,0xFA,0xB4,0xD2,0x7C,0x70,0x26,0xC1,0xD4,0xDC,0xB2,
|
||||
0x60,0x26,0x46,0xDE,0xC9,0x75,0x1E,0x76,0x3D,0xBA,0x37,0xBD,
|
||||
0xF8,0xFF,0x94,0x06,0xAD,0x9E,0x53,0x0E,0xE5,0xDB,0x38,0x2F,
|
||||
0x41,0x30,0x01,0xAE,0xB0,0x6A,0x53,0xED,0x90,0x27,0xD8,0x31,
|
||||
0x17,0x97,0x27,0xB0,0x86,0x5A,0x89,0x18,0xDA,0x3E,0xDB,0xEB,
|
||||
0xCF,0x9B,0x14,0xED,0x44,0xCE,0x6C,0xBA,0xCE,0xD4,0xBB,0x1B,
|
||||
0xDB,0x7F,0x14,0x47,0xE6,0xCC,0x25,0x4B,0x33,0x20,0x51,0x51,
|
||||
0x2B,0xD7,0xAF,0x42,0x6F,0xB8,0xF4,0x01,0x37,0x8C,0xD2,0xBF,
|
||||
0x59,0x83,0xCA,0x01,0xC6,0x4B,0x92,0xEC,0xF0,0x32,0xEA,0x15,
|
||||
0xD1,0x72,0x1D,0x03,0xF4,0x82,0xD7,0xCE,0x6E,0x74,0xFE,0xF6,
|
||||
0xD5,0x5E,0x70,0x2F,0x46,0x98,0x0C,0x82,0xB5,0xA8,0x40,0x31,
|
||||
0x90,0x0B,0x1C,0x9E,0x59,0xE7,0xC9,0x7F,0xBE,0xC7,0xE8,0xF3,
|
||||
0x23,0xA9,0x7A,0x7E,0x36,0xCC,0x88,0xBE,0x0F,0x1D,0x45,0xB7,
|
||||
0xFF,0x58,0x5A,0xC5,0x4B,0xD4,0x07,0xB2,0x2B,0x41,0x54,0xAA,
|
||||
0xCC,0x8F,0x6D,0x7E,0xBF,0x48,0xE1,0xD8,0x14,0xCC,0x5E,0xD2,
|
||||
0x0F,0x80,0x37,0xE0,0xA7,0x97,0x15,0xEE,0xF2,0x9B,0xE3,0x28,
|
||||
0x06,0xA1,0xD5,0x8B,0xB7,0xC5,0xDA,0x76,0xF5,0x50,0xAA,0x3D,
|
||||
0x8A,0x1F,0xBF,0xF0,0xEB,0x19,0xCC,0xB1,0xA3,0x13,0xD5,0x5C,
|
||||
0xDA,0x56,0xC9,0xEC,0x2E,0xF2,0x96,0x32,0x38,0x7F,0xE8,0xD7,
|
||||
0x6E,0x3C,0x04,0x68,0x04,0x3E,0x8F,0x66,0x3F,0x48,0x60,0xEE,
|
||||
0x12,0xBF,0x2D,0x5B,0x0B,0x74,0x74,0xD6,0xE6,0x94,0xF9,0x1E,
|
||||
0x6D,0xBE,0x11,0x59,0x74,0xA3,0x92,0x6F,0x12,0xFE,0xE5,0xE4,
|
||||
0x38,0x77,0x7C,0xB6,0xA9,0x32,0xDF,0x8C,0xD8,0xBE,0xC4,0xD0,
|
||||
0x73,0xB9,0x31,0xBA,0x3B,0xC8,0x32,0xB6,0x8D,0x9D,0xD3,0x00,
|
||||
0x74,0x1F,0xA7,0xBF,0x8A,0xFC,0x47,0xED,0x25,0x76,0xF6,0x93,
|
||||
0x6B,0xA4,0x24,0x66,0x3A,0xAB,0x63,0x9C,0x5A,0xE4,0xF5,0x68,
|
||||
0x34,0x23,0xB4,0x74,0x2B,0xF1,0xC9,0x78,0x23,0x8F,0x16,0xCB,
|
||||
0xE3,0x9D,0x65,0x2D,0xE3,0xFD,0xB8,0xBE,0xFC,0x84,0x8A,0xD9,
|
||||
0x22,0x22,0x2E,0x04,0xA4,0x03,0x7C,0x07,0x13,0xEB,0x57,0xA8,
|
||||
0x1A,0x23,0xF0,0xC7,0x34,0x73,0xFC,0x64,0x6C,0xEA,0x30,0x6B,
|
||||
0x4B,0xCB,0xC8,0x86,0x2F,0x83,0x85,0xDD,0xFA,0x9D,0x4B,0x7F,
|
||||
0xA2,0xC0,0x87,0xE8,0x79,0x68,0x33,0x03,0xED,0x5B,0xDD,0x3A,
|
||||
0x06,0x2B,0x3C,0xF5,0xB3,0xA2,0x78,0xA6,0x6D,0x2A,0x13,0xF8,
|
||||
0x3F,0x44,0xF8,0x2D,0xDF,0x31,0x0E,0xE0,0x74,0xAB,0x6A,0x36,
|
||||
0x45,0x97,0xE8,0x99,0xA0,0x25,0x5D,0xC1,0x64,0xF3,0x1C,0xC5,
|
||||
0x08,0x46,0x85,0x1D,0xF9,0xAB,0x48,0x19,0x5D,0xED,0x7E,0xA1,
|
||||
0xB1,0xD5,0x10,0xBD,0x7E,0xE7,0x4D,0x73,0xFA,0xF3,0x6B,0xC3,
|
||||
0x1E,0xCF,0xA2,0x68,0x35,0x90,0x46,0xF4,0xEB,0x87,0x9F,0x92,
|
||||
0x40,0x09,0x43,0x8B,0x48,0x1C,0x6C,0xD7,0x88,0x9A,0x00,0x2E,
|
||||
0xD5,0xEE,0x38,0x2B,0xC9,0x19,0x0D,0xA6,0xFC,0x02,0x6E,0x47,
|
||||
0x95,0x58,0xE4,0x47,0x56,0x77,0xE9,0xAA,0x9E,0x30,0x50,0xE2,
|
||||
0x76,0x56,0x94,0xDF,0xC8,0x1F,0x56,0xE8,0x80,0xB9,0x6E,0x71,
|
||||
0x60,0xC9,0x80,0xDD,0x98,0xED,0xD3,0xDF,0xFF,0xFF,0xFF,0xFF,
|
||||
0xFF,0xFF,0xFF,0xFF,
|
||||
};
|
||||
return BN_bin2bn(RFC3526_PRIME_8192,sizeof(RFC3526_PRIME_8192),bn);
|
||||
}
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
467
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_ctx.c
Executable file
467
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_ctx.c
Executable file
@ -0,0 +1,467 @@
|
||||
/* crypto/bn/bn_ctx.c */
|
||||
/* Written by Ulf Moeller for the OpenSSL project. */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2004 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).
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(BN_CTX_DEBUG) && !defined(BN_DEBUG)
|
||||
#ifndef NDEBUG
|
||||
#define NDEBUG
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
/* TODO list
|
||||
*
|
||||
* 1. Check a bunch of "(words+1)" type hacks in various bignum functions and
|
||||
* check they can be safely removed.
|
||||
* - Check +1 and other ugliness in BN_from_montgomery()
|
||||
*
|
||||
* 2. Consider allowing a BN_new_ex() that, at least, lets you specify an
|
||||
* appropriate 'block' size that will be honoured by bn_expand_internal() to
|
||||
* prevent piddly little reallocations. OTOH, profiling bignum expansions in
|
||||
* BN_CTX doesn't show this to be a big issue.
|
||||
*/
|
||||
|
||||
/* How many bignums are in each "pool item"; */
|
||||
#define BN_CTX_POOL_SIZE 16
|
||||
/* The stack frame info is resizing, set a first-time expansion size; */
|
||||
#define BN_CTX_START_FRAMES 32
|
||||
|
||||
/***********/
|
||||
/* BN_POOL */
|
||||
/***********/
|
||||
|
||||
/* A bundle of bignums that can be linked with other bundles */
|
||||
typedef struct bignum_pool_item
|
||||
{
|
||||
/* The bignum values */
|
||||
BIGNUM vals[BN_CTX_POOL_SIZE];
|
||||
/* Linked-list admin */
|
||||
struct bignum_pool_item *prev, *next;
|
||||
} BN_POOL_ITEM;
|
||||
/* A linked-list of bignums grouped in bundles */
|
||||
typedef struct bignum_pool
|
||||
{
|
||||
/* Linked-list admin */
|
||||
BN_POOL_ITEM *head, *current, *tail;
|
||||
/* Stack depth and allocation size */
|
||||
unsigned used, size;
|
||||
} BN_POOL;
|
||||
static void BN_POOL_init(BN_POOL *);
|
||||
static void BN_POOL_finish(BN_POOL *);
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
static void BN_POOL_reset(BN_POOL *);
|
||||
#endif
|
||||
static BIGNUM * BN_POOL_get(BN_POOL *);
|
||||
static void BN_POOL_release(BN_POOL *, unsigned int);
|
||||
|
||||
/************/
|
||||
/* BN_STACK */
|
||||
/************/
|
||||
|
||||
/* A wrapper to manage the "stack frames" */
|
||||
typedef struct bignum_ctx_stack
|
||||
{
|
||||
/* Array of indexes into the bignum stack */
|
||||
unsigned int *indexes;
|
||||
/* Number of stack frames, and the size of the allocated array */
|
||||
unsigned int depth, size;
|
||||
} BN_STACK;
|
||||
static void BN_STACK_init(BN_STACK *);
|
||||
static void BN_STACK_finish(BN_STACK *);
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
static void BN_STACK_reset(BN_STACK *);
|
||||
#endif
|
||||
static int BN_STACK_push(BN_STACK *, unsigned int);
|
||||
static unsigned int BN_STACK_pop(BN_STACK *);
|
||||
|
||||
/**********/
|
||||
/* BN_CTX */
|
||||
/**********/
|
||||
|
||||
/* The opaque BN_CTX type */
|
||||
struct bignum_ctx
|
||||
{
|
||||
/* The bignum bundles */
|
||||
BN_POOL pool;
|
||||
/* The "stack frames", if you will */
|
||||
BN_STACK stack;
|
||||
/* The number of bignums currently assigned */
|
||||
unsigned int used;
|
||||
/* Depth of stack overflow */
|
||||
int err_stack;
|
||||
/* Block "gets" until an "end" (compatibility behaviour) */
|
||||
int too_many;
|
||||
};
|
||||
|
||||
/* Enable this to find BN_CTX bugs */
|
||||
#ifdef BN_CTX_DEBUG
|
||||
static const char *ctxdbg_cur = NULL;
|
||||
static void ctxdbg(BN_CTX *ctx)
|
||||
{
|
||||
unsigned int bnidx = 0, fpidx = 0;
|
||||
BN_POOL_ITEM *item = ctx->pool.head;
|
||||
BN_STACK *stack = &ctx->stack;
|
||||
fprintf(stderr,"(%08x): ", (unsigned int)ctx);
|
||||
while(bnidx < ctx->used)
|
||||
{
|
||||
fprintf(stderr,"%02x ", item->vals[bnidx++ % BN_CTX_POOL_SIZE].dmax);
|
||||
if(!(bnidx % BN_CTX_POOL_SIZE))
|
||||
item = item->next;
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
bnidx = 0;
|
||||
fprintf(stderr," : ");
|
||||
while(fpidx < stack->depth)
|
||||
{
|
||||
while(bnidx++ < stack->indexes[fpidx])
|
||||
fprintf(stderr," ");
|
||||
fprintf(stderr,"^^ ");
|
||||
bnidx++;
|
||||
fpidx++;
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
#define CTXDBG_ENTRY(str, ctx) do { \
|
||||
ctxdbg_cur = (str); \
|
||||
fprintf(stderr,"Starting %s\n", ctxdbg_cur); \
|
||||
ctxdbg(ctx); \
|
||||
} while(0)
|
||||
#define CTXDBG_EXIT(ctx) do { \
|
||||
fprintf(stderr,"Ending %s\n", ctxdbg_cur); \
|
||||
ctxdbg(ctx); \
|
||||
} while(0)
|
||||
#define CTXDBG_RET(ctx,ret)
|
||||
#else
|
||||
#define CTXDBG_ENTRY(str, ctx)
|
||||
#define CTXDBG_EXIT(ctx)
|
||||
#define CTXDBG_RET(ctx,ret)
|
||||
#endif
|
||||
|
||||
/* This function is an evil legacy and should not be used. This implementation
|
||||
* is WYSIWYG, though I've done my best. */
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
void BN_CTX_init(BN_CTX *ctx)
|
||||
{
|
||||
/* Assume the caller obtained the context via BN_CTX_new() and so is
|
||||
* trying to reset it for use. Nothing else makes sense, least of all
|
||||
* binary compatibility from a time when they could declare a static
|
||||
* variable. */
|
||||
BN_POOL_reset(&ctx->pool);
|
||||
BN_STACK_reset(&ctx->stack);
|
||||
ctx->used = 0;
|
||||
ctx->err_stack = 0;
|
||||
ctx->too_many = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
BN_CTX *BN_CTX_new(void)
|
||||
{
|
||||
BN_CTX *ret = OPENSSL_malloc(sizeof(BN_CTX));
|
||||
if(!ret)
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
return NULL;
|
||||
}
|
||||
/* Initialise the structure */
|
||||
BN_POOL_init(&ret->pool);
|
||||
BN_STACK_init(&ret->stack);
|
||||
ret->used = 0;
|
||||
ret->err_stack = 0;
|
||||
ret->too_many = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void BN_CTX_free(BN_CTX *ctx)
|
||||
{
|
||||
if (ctx == NULL)
|
||||
return;
|
||||
#ifdef BN_CTX_DEBUG
|
||||
{
|
||||
BN_POOL_ITEM *pool = ctx->pool.head;
|
||||
fprintf(stderr,"BN_CTX_free, stack-size=%d, pool-bignums=%d\n",
|
||||
ctx->stack.size, ctx->pool.size);
|
||||
fprintf(stderr,"dmaxs: ");
|
||||
while(pool) {
|
||||
unsigned loop = 0;
|
||||
while(loop < BN_CTX_POOL_SIZE)
|
||||
fprintf(stderr,"%02x ", pool->vals[loop++].dmax);
|
||||
pool = pool->next;
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
#endif
|
||||
BN_STACK_finish(&ctx->stack);
|
||||
BN_POOL_finish(&ctx->pool);
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
|
||||
void BN_CTX_start(BN_CTX *ctx)
|
||||
{
|
||||
CTXDBG_ENTRY("BN_CTX_start", ctx);
|
||||
/* If we're already overflowing ... */
|
||||
if(ctx->err_stack || ctx->too_many)
|
||||
ctx->err_stack++;
|
||||
/* (Try to) get a new frame pointer */
|
||||
else if(!BN_STACK_push(&ctx->stack, ctx->used))
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BNerr(BN_F_BN_CTX_START,BN_R_TOO_MANY_TEMPORARY_VARIABLES);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
ctx->err_stack++;
|
||||
}
|
||||
CTXDBG_EXIT(ctx);
|
||||
}
|
||||
|
||||
void BN_CTX_end(BN_CTX *ctx)
|
||||
{
|
||||
CTXDBG_ENTRY("BN_CTX_end", ctx);
|
||||
if(ctx->err_stack)
|
||||
ctx->err_stack--;
|
||||
else
|
||||
{
|
||||
unsigned int fp = BN_STACK_pop(&ctx->stack);
|
||||
/* Does this stack frame have anything to release? */
|
||||
if(fp < ctx->used)
|
||||
BN_POOL_release(&ctx->pool, ctx->used - fp);
|
||||
ctx->used = fp;
|
||||
/* Unjam "too_many" in case "get" had failed */
|
||||
ctx->too_many = 0;
|
||||
}
|
||||
CTXDBG_EXIT(ctx);
|
||||
}
|
||||
|
||||
BIGNUM *BN_CTX_get(BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM *ret;
|
||||
CTXDBG_ENTRY("BN_CTX_get", ctx);
|
||||
if(ctx->err_stack || ctx->too_many) return NULL;
|
||||
if((ret = BN_POOL_get(&ctx->pool)) == NULL)
|
||||
{
|
||||
/* Setting too_many prevents repeated "get" attempts from
|
||||
* cluttering the error stack. */
|
||||
ctx->too_many = 1;
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BNerr(BN_F_BN_CTX_GET,BN_R_TOO_MANY_TEMPORARY_VARIABLES);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
return NULL;
|
||||
}
|
||||
/* OK, make sure the returned bignum is "zero" */
|
||||
BN_zero(ret);
|
||||
ctx->used++;
|
||||
CTXDBG_RET(ctx, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/************/
|
||||
/* BN_STACK */
|
||||
/************/
|
||||
|
||||
static void BN_STACK_init(BN_STACK *st)
|
||||
{
|
||||
st->indexes = NULL;
|
||||
st->depth = st->size = 0;
|
||||
}
|
||||
|
||||
static void BN_STACK_finish(BN_STACK *st)
|
||||
{
|
||||
if(st->size) OPENSSL_free(st->indexes);
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
static void BN_STACK_reset(BN_STACK *st)
|
||||
{
|
||||
st->depth = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int BN_STACK_push(BN_STACK *st, unsigned int idx)
|
||||
{
|
||||
if(st->depth == st->size)
|
||||
/* Need to expand */
|
||||
{
|
||||
unsigned int newsize = (st->size ?
|
||||
(st->size * 3 / 2) : BN_CTX_START_FRAMES);
|
||||
unsigned int *newitems = OPENSSL_malloc(newsize *
|
||||
sizeof(unsigned int));
|
||||
if(!newitems) return 0;
|
||||
if(st->depth)
|
||||
memcpy(newitems, st->indexes, st->depth *
|
||||
sizeof(unsigned int));
|
||||
if(st->size) OPENSSL_free(st->indexes);
|
||||
st->indexes = newitems;
|
||||
st->size = newsize;
|
||||
}
|
||||
st->indexes[(st->depth)++] = idx;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static unsigned int BN_STACK_pop(BN_STACK *st)
|
||||
{
|
||||
return st->indexes[--(st->depth)];
|
||||
}
|
||||
|
||||
/***********/
|
||||
/* BN_POOL */
|
||||
/***********/
|
||||
|
||||
static void BN_POOL_init(BN_POOL *p)
|
||||
{
|
||||
p->head = p->current = p->tail = NULL;
|
||||
p->used = p->size = 0;
|
||||
}
|
||||
|
||||
static void BN_POOL_finish(BN_POOL *p)
|
||||
{
|
||||
while(p->head)
|
||||
{
|
||||
unsigned int loop = 0;
|
||||
BIGNUM *bn = p->head->vals;
|
||||
while(loop++ < BN_CTX_POOL_SIZE)
|
||||
{
|
||||
if(bn->d) BN_clear_free(bn);
|
||||
bn++;
|
||||
}
|
||||
p->current = p->head->next;
|
||||
OPENSSL_free(p->head);
|
||||
p->head = p->current;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
static void BN_POOL_reset(BN_POOL *p)
|
||||
{
|
||||
BN_POOL_ITEM *item = p->head;
|
||||
while(item)
|
||||
{
|
||||
unsigned int loop = 0;
|
||||
BIGNUM *bn = item->vals;
|
||||
while(loop++ < BN_CTX_POOL_SIZE)
|
||||
{
|
||||
if(bn->d) BN_clear(bn);
|
||||
bn++;
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
p->current = p->head;
|
||||
p->used = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static BIGNUM *BN_POOL_get(BN_POOL *p)
|
||||
{
|
||||
if(p->used == p->size)
|
||||
{
|
||||
BIGNUM *bn;
|
||||
unsigned int loop = 0;
|
||||
BN_POOL_ITEM *item = OPENSSL_malloc(sizeof(BN_POOL_ITEM));
|
||||
if(!item) return NULL;
|
||||
/* Initialise the structure */
|
||||
bn = item->vals;
|
||||
while(loop++ < BN_CTX_POOL_SIZE)
|
||||
BN_init(bn++);
|
||||
item->prev = p->tail;
|
||||
item->next = NULL;
|
||||
/* Link it in */
|
||||
if(!p->head)
|
||||
p->head = p->current = p->tail = item;
|
||||
else
|
||||
{
|
||||
p->tail->next = item;
|
||||
p->tail = item;
|
||||
p->current = item;
|
||||
}
|
||||
p->size += BN_CTX_POOL_SIZE;
|
||||
p->used++;
|
||||
/* Return the first bignum from the new pool */
|
||||
return item->vals;
|
||||
}
|
||||
if(!p->used)
|
||||
p->current = p->head;
|
||||
else if((p->used % BN_CTX_POOL_SIZE) == 0)
|
||||
p->current = p->current->next;
|
||||
return p->current->vals + ((p->used++) % BN_CTX_POOL_SIZE);
|
||||
}
|
||||
|
||||
static void BN_POOL_release(BN_POOL *p, unsigned int num)
|
||||
{
|
||||
unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;
|
||||
p->used -= num;
|
||||
while(num--)
|
||||
{
|
||||
bn_check_top(p->current->vals + offset);
|
||||
if(!offset)
|
||||
{
|
||||
offset = BN_CTX_POOL_SIZE - 1;
|
||||
p->current = p->current->prev;
|
||||
}
|
||||
else
|
||||
offset--;
|
||||
}
|
||||
}
|
||||
|
404
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_div.c
Executable file
404
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_div.c
Executable file
@ -0,0 +1,404 @@
|
||||
/* crypto/bn/bn_div.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <openssl/bn.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
|
||||
/* The old slow way */
|
||||
#if 0
|
||||
int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
int i,nm,nd;
|
||||
int ret = 0;
|
||||
BIGNUM *D;
|
||||
|
||||
bn_check_top(m);
|
||||
bn_check_top(d);
|
||||
if (BN_is_zero(d))
|
||||
{
|
||||
BNerr(BN_F_BN_DIV,BN_R_DIV_BY_ZERO);
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (BN_ucmp(m,d) < 0)
|
||||
{
|
||||
if (rem != NULL)
|
||||
{ if (BN_copy(rem,m) == NULL) return(0); }
|
||||
if (dv != NULL) BN_zero(dv);
|
||||
return(1);
|
||||
}
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
D = BN_CTX_get(ctx);
|
||||
if (dv == NULL) dv = BN_CTX_get(ctx);
|
||||
if (rem == NULL) rem = BN_CTX_get(ctx);
|
||||
if (D == NULL || dv == NULL || rem == NULL)
|
||||
goto end;
|
||||
|
||||
nd=BN_num_bits(d);
|
||||
nm=BN_num_bits(m);
|
||||
if (BN_copy(D,d) == NULL) goto end;
|
||||
if (BN_copy(rem,m) == NULL) goto end;
|
||||
|
||||
/* The next 2 are needed so we can do a dv->d[0]|=1 later
|
||||
* since BN_lshift1 will only work once there is a value :-) */
|
||||
BN_zero(dv);
|
||||
bn_wexpand(dv,1);
|
||||
dv->top=1;
|
||||
|
||||
if (!BN_lshift(D,D,nm-nd)) goto end;
|
||||
for (i=nm-nd; i>=0; i--)
|
||||
{
|
||||
if (!BN_lshift1(dv,dv)) goto end;
|
||||
if (BN_ucmp(rem,D) >= 0)
|
||||
{
|
||||
dv->d[0]|=1;
|
||||
if (!BN_usub(rem,rem,D)) goto end;
|
||||
}
|
||||
/* CAN IMPROVE (and have now :=) */
|
||||
if (!BN_rshift1(D,D)) goto end;
|
||||
}
|
||||
rem->neg=BN_is_zero(rem)?0:m->neg;
|
||||
dv->neg=m->neg^d->neg;
|
||||
ret = 1;
|
||||
end:
|
||||
BN_CTX_end(ctx);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) \
|
||||
&& !defined(PEDANTIC) && !defined(BN_DIV3W)
|
||||
# if defined(__GNUC__) && __GNUC__>=2
|
||||
# if defined(__i386) || defined (__i386__)
|
||||
/*
|
||||
* There were two reasons for implementing this template:
|
||||
* - GNU C generates a call to a function (__udivdi3 to be exact)
|
||||
* in reply to ((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0 (I fail to
|
||||
* understand why...);
|
||||
* - divl doesn't only calculate quotient, but also leaves
|
||||
* remainder in %edx which we can definitely use here:-)
|
||||
*
|
||||
* <appro@fy.chalmers.se>
|
||||
*/
|
||||
# define bn_div_words(n0,n1,d0) \
|
||||
({ asm volatile ( \
|
||||
"divl %4" \
|
||||
: "=a"(q), "=d"(rem) \
|
||||
: "a"(n1), "d"(n0), "g"(d0) \
|
||||
: "cc"); \
|
||||
q; \
|
||||
})
|
||||
# define REMAINDER_IS_ALREADY_CALCULATED
|
||||
# elif defined(__x86_64) && defined(SIXTY_FOUR_BIT_LONG)
|
||||
/*
|
||||
* Same story here, but it's 128-bit by 64-bit division. Wow!
|
||||
* <appro@fy.chalmers.se>
|
||||
*/
|
||||
# define bn_div_words(n0,n1,d0) \
|
||||
({ asm volatile ( \
|
||||
"divq %4" \
|
||||
: "=a"(q), "=d"(rem) \
|
||||
: "a"(n1), "d"(n0), "g"(d0) \
|
||||
: "cc"); \
|
||||
q; \
|
||||
})
|
||||
# define REMAINDER_IS_ALREADY_CALCULATED
|
||||
# endif /* __<cpu> */
|
||||
# endif /* __GNUC__ */
|
||||
#endif /* OPENSSL_NO_ASM */
|
||||
|
||||
|
||||
/* BN_div computes dv := num / divisor, rounding towards zero, and sets up
|
||||
* rm such that dv*divisor + rm = num holds.
|
||||
* Thus:
|
||||
* dv->neg == num->neg ^ divisor->neg (unless the result is zero)
|
||||
* rm->neg == num->neg (unless the remainder is zero)
|
||||
* If 'dv' or 'rm' is NULL, the respective value is not returned.
|
||||
*/
|
||||
int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
int norm_shift,i,loop;
|
||||
BIGNUM *tmp,wnum,*snum,*sdiv,*res;
|
||||
BN_ULONG *resp,*wnump;
|
||||
BN_ULONG d0,d1;
|
||||
int num_n,div_n;
|
||||
|
||||
bn_check_top(dv);
|
||||
bn_check_top(rm);
|
||||
bn_check_top(num);
|
||||
bn_check_top(divisor);
|
||||
|
||||
if (BN_is_zero(divisor))
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BNerr(BN_F_BN_DIV,BN_R_DIV_BY_ZERO);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (BN_ucmp(num,divisor) < 0)
|
||||
{
|
||||
if (rm != NULL)
|
||||
{ if (BN_copy(rm,num) == NULL) return(0); }
|
||||
if (dv != NULL) BN_zero(dv);
|
||||
return(1);
|
||||
}
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
tmp=BN_CTX_get(ctx);
|
||||
snum=BN_CTX_get(ctx);
|
||||
sdiv=BN_CTX_get(ctx);
|
||||
if (dv == NULL)
|
||||
res=BN_CTX_get(ctx);
|
||||
else res=dv;
|
||||
if (sdiv == NULL || res == NULL) goto err;
|
||||
|
||||
/* First we normalise the numbers */
|
||||
norm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2);
|
||||
if (!(BN_lshift(sdiv,divisor,norm_shift))) goto err;
|
||||
sdiv->neg=0;
|
||||
norm_shift+=BN_BITS2;
|
||||
if (!(BN_lshift(snum,num,norm_shift))) goto err;
|
||||
snum->neg=0;
|
||||
div_n=sdiv->top;
|
||||
num_n=snum->top;
|
||||
loop=num_n-div_n;
|
||||
/* Lets setup a 'window' into snum
|
||||
* This is the part that corresponds to the current
|
||||
* 'area' being divided */
|
||||
wnum.neg = 0;
|
||||
wnum.d = &(snum->d[loop]);
|
||||
wnum.top = div_n;
|
||||
/* only needed when BN_ucmp messes up the values between top and max */
|
||||
wnum.dmax = snum->dmax - loop; /* so we don't step out of bounds */
|
||||
|
||||
/* Get the top 2 words of sdiv */
|
||||
/* div_n=sdiv->top; */
|
||||
d0=sdiv->d[div_n-1];
|
||||
d1=(div_n == 1)?0:sdiv->d[div_n-2];
|
||||
|
||||
/* pointer to the 'top' of snum */
|
||||
wnump= &(snum->d[num_n-1]);
|
||||
|
||||
/* Setup to 'res' */
|
||||
res->neg= (num->neg^divisor->neg);
|
||||
if (!bn_wexpand(res,(loop+1))) goto err;
|
||||
res->top=loop;
|
||||
resp= &(res->d[loop-1]);
|
||||
|
||||
/* space for temp */
|
||||
if (!bn_wexpand(tmp,(div_n+1))) goto err;
|
||||
|
||||
if (BN_ucmp(&wnum,sdiv) >= 0)
|
||||
{
|
||||
/* If BN_DEBUG_RAND is defined BN_ucmp changes (via
|
||||
* bn_pollute) the const bignum arguments =>
|
||||
* clean the values between top and max again */
|
||||
bn_clear_top2max(&wnum);
|
||||
bn_sub_words(wnum.d, wnum.d, sdiv->d, div_n);
|
||||
*resp=1;
|
||||
}
|
||||
else
|
||||
res->top--;
|
||||
/* if res->top == 0 then clear the neg value otherwise decrease
|
||||
* the resp pointer */
|
||||
if (res->top == 0)
|
||||
res->neg = 0;
|
||||
else
|
||||
resp--;
|
||||
|
||||
for (i=0; i<loop-1; i++, wnump--, resp--)
|
||||
{
|
||||
BN_ULONG q,l0;
|
||||
/* the first part of the loop uses the top two words of
|
||||
* snum and sdiv to calculate a BN_ULONG q such that
|
||||
* | wnum - sdiv * q | < sdiv */
|
||||
#if defined(BN_DIV3W) && !defined(OPENSSL_NO_ASM)
|
||||
BN_ULONG bn_div_3_words(BN_ULONG*,BN_ULONG,BN_ULONG);
|
||||
q=bn_div_3_words(wnump,d1,d0);
|
||||
#else
|
||||
BN_ULONG n0,n1,rem=0;
|
||||
|
||||
n0=wnump[0];
|
||||
n1=wnump[-1];
|
||||
if (n0 == d0)
|
||||
q=BN_MASK2;
|
||||
else /* n0 < d0 */
|
||||
{
|
||||
#ifdef BN_LLONG
|
||||
BN_ULLONG t2;
|
||||
|
||||
#if defined(BN_LLONG) && defined(BN_DIV2W) && !defined(bn_div_words)
|
||||
q=(BN_ULONG)(((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0);
|
||||
#else
|
||||
q=bn_div_words(n0,n1,d0);
|
||||
#ifdef BN_DEBUG_LEVITTE
|
||||
fprintf(stderr,"DEBUG: bn_div_words(0x%08X,0x%08X,0x%08\
|
||||
X) -> 0x%08X\n",
|
||||
n0, n1, d0, q);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef REMAINDER_IS_ALREADY_CALCULATED
|
||||
/*
|
||||
* rem doesn't have to be BN_ULLONG. The least we
|
||||
* know it's less that d0, isn't it?
|
||||
*/
|
||||
rem=(n1-q*d0)&BN_MASK2;
|
||||
#endif
|
||||
t2=(BN_ULLONG)d1*q;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (t2 <= ((((BN_ULLONG)rem)<<BN_BITS2)|wnump[-2]))
|
||||
break;
|
||||
q--;
|
||||
rem += d0;
|
||||
if (rem < d0) break; /* don't let rem overflow */
|
||||
t2 -= d1;
|
||||
}
|
||||
#else /* !BN_LLONG */
|
||||
BN_ULONG t2l,t2h,ql,qh;
|
||||
|
||||
q=bn_div_words(n0,n1,d0);
|
||||
#ifdef BN_DEBUG_LEVITTE
|
||||
fprintf(stderr,"DEBUG: bn_div_words(0x%08X,0x%08X,0x%08\
|
||||
X) -> 0x%08X\n",
|
||||
n0, n1, d0, q);
|
||||
#endif
|
||||
#ifndef REMAINDER_IS_ALREADY_CALCULATED
|
||||
rem=(n1-q*d0)&BN_MASK2;
|
||||
#endif
|
||||
|
||||
#if defined(BN_UMULT_LOHI)
|
||||
BN_UMULT_LOHI(t2l,t2h,d1,q);
|
||||
#elif defined(BN_UMULT_HIGH)
|
||||
t2l = d1 * q;
|
||||
t2h = BN_UMULT_HIGH(d1,q);
|
||||
#else
|
||||
t2l=LBITS(d1); t2h=HBITS(d1);
|
||||
ql =LBITS(q); qh =HBITS(q);
|
||||
mul64(t2l,t2h,ql,qh); /* t2=(BN_ULLONG)d1*q; */
|
||||
#endif
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if ((t2h < rem) ||
|
||||
((t2h == rem) && (t2l <= wnump[-2])))
|
||||
break;
|
||||
q--;
|
||||
rem += d0;
|
||||
if (rem < d0) break; /* don't let rem overflow */
|
||||
if (t2l < d1) t2h--; t2l -= d1;
|
||||
}
|
||||
#endif /* !BN_LLONG */
|
||||
}
|
||||
#endif /* !BN_DIV3W */
|
||||
|
||||
l0=bn_mul_words(tmp->d,sdiv->d,div_n,q);
|
||||
tmp->d[div_n]=l0;
|
||||
wnum.d--;
|
||||
/* ingore top values of the bignums just sub the two
|
||||
* BN_ULONG arrays with bn_sub_words */
|
||||
if (bn_sub_words(wnum.d, wnum.d, tmp->d, div_n+1))
|
||||
{
|
||||
/* Note: As we have considered only the leading
|
||||
* two BN_ULONGs in the calculation of q, sdiv * q
|
||||
* might be greater than wnum (but then (q-1) * sdiv
|
||||
* is less or equal than wnum)
|
||||
*/
|
||||
q--;
|
||||
if (bn_add_words(wnum.d, wnum.d, sdiv->d, div_n))
|
||||
/* we can't have an overflow here (assuming
|
||||
* that q != 0, but if q == 0 then tmp is
|
||||
* zero anyway) */
|
||||
(*wnump)++;
|
||||
}
|
||||
/* store part of the result */
|
||||
*resp = q;
|
||||
}
|
||||
bn_correct_top(snum);
|
||||
if (rm != NULL)
|
||||
{
|
||||
/* Keep a copy of the neg flag in num because if rm==num
|
||||
* BN_rshift() will overwrite it.
|
||||
*/
|
||||
int neg = num->neg;
|
||||
BN_rshift(rm,snum,norm_shift);
|
||||
if (!BN_is_zero(rm))
|
||||
rm->neg = neg;
|
||||
bn_check_top(rm);
|
||||
}
|
||||
BN_CTX_end(ctx);
|
||||
return(1);
|
||||
err:
|
||||
bn_check_top(rm);
|
||||
BN_CTX_end(ctx);
|
||||
return(0);
|
||||
}
|
||||
|
||||
#endif
|
1022
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_exp.c
Executable file
1022
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_exp.c
Executable file
File diff suppressed because it is too large
Load Diff
497
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_gcd.c
Executable file
497
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_gcd.c
Executable file
@ -0,0 +1,497 @@
|
||||
/* crypto/bn/bn_gcd.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2001 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).
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
static BIGNUM *euclid(BIGNUM *a, BIGNUM *b);
|
||||
|
||||
int BN_gcd(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM *a,*b,*t;
|
||||
int ret=0;
|
||||
|
||||
bn_check_top(in_a);
|
||||
bn_check_top(in_b);
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
a = BN_CTX_get(ctx);
|
||||
b = BN_CTX_get(ctx);
|
||||
if (a == NULL || b == NULL) goto err;
|
||||
|
||||
if (BN_copy(a,in_a) == NULL) goto err;
|
||||
if (BN_copy(b,in_b) == NULL) goto err;
|
||||
a->neg = 0;
|
||||
b->neg = 0;
|
||||
|
||||
if (BN_cmp(a,b) < 0) { t=a; a=b; b=t; }
|
||||
t=euclid(a,b);
|
||||
if (t == NULL) goto err;
|
||||
|
||||
if (BN_copy(r,t) == NULL) goto err;
|
||||
ret=1;
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
bn_check_top(r);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static BIGNUM *euclid(BIGNUM *a, BIGNUM *b)
|
||||
{
|
||||
BIGNUM *t;
|
||||
int shifts=0;
|
||||
|
||||
bn_check_top(a);
|
||||
bn_check_top(b);
|
||||
|
||||
/* 0 <= b <= a */
|
||||
while (!BN_is_zero(b))
|
||||
{
|
||||
/* 0 < b <= a */
|
||||
|
||||
if (BN_is_odd(a))
|
||||
{
|
||||
if (BN_is_odd(b))
|
||||
{
|
||||
if (!BN_sub(a,a,b)) goto err;
|
||||
if (!BN_rshift1(a,a)) goto err;
|
||||
if (BN_cmp(a,b) < 0)
|
||||
{ t=a; a=b; b=t; }
|
||||
}
|
||||
else /* a odd - b even */
|
||||
{
|
||||
if (!BN_rshift1(b,b)) goto err;
|
||||
if (BN_cmp(a,b) < 0)
|
||||
{ t=a; a=b; b=t; }
|
||||
}
|
||||
}
|
||||
else /* a is even */
|
||||
{
|
||||
if (BN_is_odd(b))
|
||||
{
|
||||
if (!BN_rshift1(a,a)) goto err;
|
||||
if (BN_cmp(a,b) < 0)
|
||||
{ t=a; a=b; b=t; }
|
||||
}
|
||||
else /* a even - b even */
|
||||
{
|
||||
if (!BN_rshift1(a,a)) goto err;
|
||||
if (!BN_rshift1(b,b)) goto err;
|
||||
shifts++;
|
||||
}
|
||||
}
|
||||
/* 0 <= b <= a */
|
||||
}
|
||||
|
||||
if (shifts)
|
||||
{
|
||||
if (!BN_lshift(a,a,shifts)) goto err;
|
||||
}
|
||||
bn_check_top(a);
|
||||
return(a);
|
||||
err:
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
/* solves ax == 1 (mod n) */
|
||||
BIGNUM *BN_mod_inverse(BIGNUM *in,
|
||||
const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM *A,*B,*X,*Y,*M,*D,*T,*R=NULL;
|
||||
BIGNUM *ret=NULL;
|
||||
int sign;
|
||||
|
||||
bn_check_top(a);
|
||||
bn_check_top(n);
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
A = BN_CTX_get(ctx);
|
||||
B = BN_CTX_get(ctx);
|
||||
X = BN_CTX_get(ctx);
|
||||
D = BN_CTX_get(ctx);
|
||||
M = BN_CTX_get(ctx);
|
||||
Y = BN_CTX_get(ctx);
|
||||
T = BN_CTX_get(ctx);
|
||||
if (T == NULL) goto err;
|
||||
|
||||
if (in == NULL)
|
||||
R=BN_new();
|
||||
else
|
||||
R=in;
|
||||
if (R == NULL) goto err;
|
||||
|
||||
BN_one(X);
|
||||
BN_zero(Y);
|
||||
if (BN_copy(B,a) == NULL) goto err;
|
||||
if (BN_copy(A,n) == NULL) goto err;
|
||||
A->neg = 0;
|
||||
if (B->neg || (BN_ucmp(B, A) >= 0))
|
||||
{
|
||||
if (!BN_nnmod(B, B, A, ctx)) goto err;
|
||||
}
|
||||
sign = -1;
|
||||
/* From B = a mod |n|, A = |n| it follows that
|
||||
*
|
||||
* 0 <= B < A,
|
||||
* -sign*X*a == B (mod |n|),
|
||||
* sign*Y*a == A (mod |n|).
|
||||
*/
|
||||
|
||||
if (BN_is_odd(n) && (BN_num_bits(n) <= (BN_BITS <= 32 ? 450 : 2048)))
|
||||
{
|
||||
/* Binary inversion algorithm; requires odd modulus.
|
||||
* This is faster than the general algorithm if the modulus
|
||||
* is sufficiently small (about 400 .. 500 bits on 32-bit
|
||||
* sytems, but much more on 64-bit systems) */
|
||||
int shift;
|
||||
|
||||
while (!BN_is_zero(B))
|
||||
{
|
||||
/*
|
||||
* 0 < B < |n|,
|
||||
* 0 < A <= |n|,
|
||||
* (1) -sign*X*a == B (mod |n|),
|
||||
* (2) sign*Y*a == A (mod |n|)
|
||||
*/
|
||||
|
||||
/* Now divide B by the maximum possible power of two in the integers,
|
||||
* and divide X by the same value mod |n|.
|
||||
* When we're done, (1) still holds. */
|
||||
shift = 0;
|
||||
while (!BN_is_bit_set(B, shift)) /* note that 0 < B */
|
||||
{
|
||||
shift++;
|
||||
|
||||
if (BN_is_odd(X))
|
||||
{
|
||||
if (!BN_uadd(X, X, n)) goto err;
|
||||
}
|
||||
/* now X is even, so we can easily divide it by two */
|
||||
if (!BN_rshift1(X, X)) goto err;
|
||||
}
|
||||
if (shift > 0)
|
||||
{
|
||||
if (!BN_rshift(B, B, shift)) goto err;
|
||||
}
|
||||
|
||||
|
||||
/* Same for A and Y. Afterwards, (2) still holds. */
|
||||
shift = 0;
|
||||
while (!BN_is_bit_set(A, shift)) /* note that 0 < A */
|
||||
{
|
||||
shift++;
|
||||
|
||||
if (BN_is_odd(Y))
|
||||
{
|
||||
if (!BN_uadd(Y, Y, n)) goto err;
|
||||
}
|
||||
/* now Y is even */
|
||||
if (!BN_rshift1(Y, Y)) goto err;
|
||||
}
|
||||
if (shift > 0)
|
||||
{
|
||||
if (!BN_rshift(A, A, shift)) goto err;
|
||||
}
|
||||
|
||||
|
||||
/* We still have (1) and (2).
|
||||
* Both A and B are odd.
|
||||
* The following computations ensure that
|
||||
*
|
||||
* 0 <= B < |n|,
|
||||
* 0 < A < |n|,
|
||||
* (1) -sign*X*a == B (mod |n|),
|
||||
* (2) sign*Y*a == A (mod |n|),
|
||||
*
|
||||
* and that either A or B is even in the next iteration.
|
||||
*/
|
||||
if (BN_ucmp(B, A) >= 0)
|
||||
{
|
||||
/* -sign*(X + Y)*a == B - A (mod |n|) */
|
||||
if (!BN_uadd(X, X, Y)) goto err;
|
||||
/* NB: we could use BN_mod_add_quick(X, X, Y, n), but that
|
||||
* actually makes the algorithm slower */
|
||||
if (!BN_usub(B, B, A)) goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* sign*(X + Y)*a == A - B (mod |n|) */
|
||||
if (!BN_uadd(Y, Y, X)) goto err;
|
||||
/* as above, BN_mod_add_quick(Y, Y, X, n) would slow things down */
|
||||
if (!BN_usub(A, A, B)) goto err;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* general inversion algorithm */
|
||||
|
||||
while (!BN_is_zero(B))
|
||||
{
|
||||
BIGNUM *tmp;
|
||||
|
||||
/*
|
||||
* 0 < B < A,
|
||||
* (*) -sign*X*a == B (mod |n|),
|
||||
* sign*Y*a == A (mod |n|)
|
||||
*/
|
||||
|
||||
/* (D, M) := (A/B, A%B) ... */
|
||||
if (BN_num_bits(A) == BN_num_bits(B))
|
||||
{
|
||||
if (!BN_one(D)) goto err;
|
||||
if (!BN_sub(M,A,B)) goto err;
|
||||
}
|
||||
else if (BN_num_bits(A) == BN_num_bits(B) + 1)
|
||||
{
|
||||
/* A/B is 1, 2, or 3 */
|
||||
if (!BN_lshift1(T,B)) goto err;
|
||||
if (BN_ucmp(A,T) < 0)
|
||||
{
|
||||
/* A < 2*B, so D=1 */
|
||||
if (!BN_one(D)) goto err;
|
||||
if (!BN_sub(M,A,B)) goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* A >= 2*B, so D=2 or D=3 */
|
||||
if (!BN_sub(M,A,T)) goto err;
|
||||
if (!BN_add(D,T,B)) goto err; /* use D (:= 3*B) as temp */
|
||||
if (BN_ucmp(A,D) < 0)
|
||||
{
|
||||
/* A < 3*B, so D=2 */
|
||||
if (!BN_set_word(D,2)) goto err;
|
||||
/* M (= A - 2*B) already has the correct value */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* only D=3 remains */
|
||||
if (!BN_set_word(D,3)) goto err;
|
||||
/* currently M = A - 2*B, but we need M = A - 3*B */
|
||||
if (!BN_sub(M,M,B)) goto err;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!BN_div(D,M,A,B,ctx)) goto err;
|
||||
}
|
||||
|
||||
/* Now
|
||||
* A = D*B + M;
|
||||
* thus we have
|
||||
* (**) sign*Y*a == D*B + M (mod |n|).
|
||||
*/
|
||||
|
||||
tmp=A; /* keep the BIGNUM object, the value does not matter */
|
||||
|
||||
/* (A, B) := (B, A mod B) ... */
|
||||
A=B;
|
||||
B=M;
|
||||
/* ... so we have 0 <= B < A again */
|
||||
|
||||
/* Since the former M is now B and the former B is now A,
|
||||
* (**) translates into
|
||||
* sign*Y*a == D*A + B (mod |n|),
|
||||
* i.e.
|
||||
* sign*Y*a - D*A == B (mod |n|).
|
||||
* Similarly, (*) translates into
|
||||
* -sign*X*a == A (mod |n|).
|
||||
*
|
||||
* Thus,
|
||||
* sign*Y*a + D*sign*X*a == B (mod |n|),
|
||||
* i.e.
|
||||
* sign*(Y + D*X)*a == B (mod |n|).
|
||||
*
|
||||
* So if we set (X, Y, sign) := (Y + D*X, X, -sign), we arrive back at
|
||||
* -sign*X*a == B (mod |n|),
|
||||
* sign*Y*a == A (mod |n|).
|
||||
* Note that X and Y stay non-negative all the time.
|
||||
*/
|
||||
|
||||
/* most of the time D is very small, so we can optimize tmp := D*X+Y */
|
||||
if (BN_is_one(D))
|
||||
{
|
||||
if (!BN_add(tmp,X,Y)) goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (BN_is_word(D,2))
|
||||
{
|
||||
if (!BN_lshift1(tmp,X)) goto err;
|
||||
}
|
||||
else if (BN_is_word(D,4))
|
||||
{
|
||||
if (!BN_lshift(tmp,X,2)) goto err;
|
||||
}
|
||||
else if (D->top == 1)
|
||||
{
|
||||
if (!BN_copy(tmp,X)) goto err;
|
||||
if (!BN_mul_word(tmp,D->d[0])) goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!BN_mul(tmp,D,X,ctx)) goto err;
|
||||
}
|
||||
if (!BN_add(tmp,tmp,Y)) goto err;
|
||||
}
|
||||
|
||||
M=Y; /* keep the BIGNUM object, the value does not matter */
|
||||
Y=X;
|
||||
X=tmp;
|
||||
sign = -sign;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The while loop (Euclid's algorithm) ends when
|
||||
* A == gcd(a,n);
|
||||
* we have
|
||||
* sign*Y*a == A (mod |n|),
|
||||
* where Y is non-negative.
|
||||
*/
|
||||
|
||||
if (sign < 0)
|
||||
{
|
||||
if (!BN_sub(Y,n,Y)) goto err;
|
||||
}
|
||||
/* Now Y*a == A (mod |n|). */
|
||||
|
||||
|
||||
if (BN_is_one(A))
|
||||
{
|
||||
/* Y*a == 1 (mod |n|) */
|
||||
if (!Y->neg && BN_ucmp(Y,n) < 0)
|
||||
{
|
||||
if (!BN_copy(R,Y)) goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!BN_nnmod(R,Y,n,ctx)) goto err;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BNerr(BN_F_BN_MOD_INVERSE,BN_R_NO_INVERSE);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
goto err;
|
||||
}
|
||||
ret=R;
|
||||
err:
|
||||
if ((ret == NULL) && (in == NULL)) BN_free(R);
|
||||
BN_CTX_end(ctx);
|
||||
bn_check_top(ret);
|
||||
return(ret);
|
||||
}
|
866
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_lib.c
Executable file
866
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_lib.c
Executable file
@ -0,0 +1,866 @@
|
||||
/* crypto/bn/bn_lib.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef BN_DEBUG
|
||||
# undef NDEBUG /* avoid conflicting definitions */
|
||||
# define NDEBUG
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
const char *BN_version="Big Number" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
/* This stuff appears to be completely unused, so is deprecated */
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
/* For a 32 bit machine
|
||||
* 2 - 4 == 128
|
||||
* 3 - 8 == 256
|
||||
* 4 - 16 == 512
|
||||
* 5 - 32 == 1024
|
||||
* 6 - 64 == 2048
|
||||
* 7 - 128 == 4096
|
||||
* 8 - 256 == 8192
|
||||
*/
|
||||
static int bn_limit_bits=0;
|
||||
static int bn_limit_num=8; /* (1<<bn_limit_bits) */
|
||||
static int bn_limit_bits_low=0;
|
||||
static int bn_limit_num_low=8; /* (1<<bn_limit_bits_low) */
|
||||
static int bn_limit_bits_high=0;
|
||||
static int bn_limit_num_high=8; /* (1<<bn_limit_bits_high) */
|
||||
static int bn_limit_bits_mont=0;
|
||||
static int bn_limit_num_mont=8; /* (1<<bn_limit_bits_mont) */
|
||||
|
||||
void BN_set_params(int mult, int high, int low, int mont)
|
||||
{
|
||||
if (mult >= 0)
|
||||
{
|
||||
if (mult > (int)(sizeof(int)*8)-1)
|
||||
mult=sizeof(int)*8-1;
|
||||
bn_limit_bits=mult;
|
||||
bn_limit_num=1<<mult;
|
||||
}
|
||||
if (high >= 0)
|
||||
{
|
||||
if (high > (int)(sizeof(int)*8)-1)
|
||||
high=sizeof(int)*8-1;
|
||||
bn_limit_bits_high=high;
|
||||
bn_limit_num_high=1<<high;
|
||||
}
|
||||
if (low >= 0)
|
||||
{
|
||||
if (low > (int)(sizeof(int)*8)-1)
|
||||
low=sizeof(int)*8-1;
|
||||
bn_limit_bits_low=low;
|
||||
bn_limit_num_low=1<<low;
|
||||
}
|
||||
if (mont >= 0)
|
||||
{
|
||||
if (mont > (int)(sizeof(int)*8)-1)
|
||||
mont=sizeof(int)*8-1;
|
||||
bn_limit_bits_mont=mont;
|
||||
bn_limit_num_mont=1<<mont;
|
||||
}
|
||||
}
|
||||
|
||||
int BN_get_params(int which)
|
||||
{
|
||||
if (which == 0) return(bn_limit_bits);
|
||||
else if (which == 1) return(bn_limit_bits_high);
|
||||
else if (which == 2) return(bn_limit_bits_low);
|
||||
else if (which == 3) return(bn_limit_bits_mont);
|
||||
else return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
const BIGNUM *BN_value_one(void)
|
||||
{
|
||||
static BN_ULONG data_one=1L;
|
||||
static BIGNUM const_one={&data_one,1,1,0,BN_FLG_STATIC_DATA};
|
||||
|
||||
return(&const_one);
|
||||
}
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
char *BN_options(void)
|
||||
{
|
||||
static int init=0;
|
||||
static char data[16];
|
||||
|
||||
if (!init)
|
||||
{
|
||||
init++;
|
||||
|
||||
#ifdef BN_LLONG
|
||||
BIO_snprintf(data,sizeof data,"bn(%d,%d)",
|
||||
(int)sizeof(BN_ULLONG)*8,(int)sizeof(BN_ULONG)*8);
|
||||
#else
|
||||
BIO_snprintf(data,sizeof data,"bn(%d,%d)",
|
||||
(int)sizeof(BN_ULONG)*8,(int)sizeof(BN_ULONG)*8);
|
||||
#endif
|
||||
}
|
||||
return(data);
|
||||
}
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
int BN_num_bits_word(BN_ULONG l)
|
||||
{
|
||||
static const char bits[256]={
|
||||
0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,
|
||||
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
|
||||
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
};
|
||||
|
||||
#if defined(SIXTY_FOUR_BIT_LONG)
|
||||
if (l & 0xffffffff00000000L)
|
||||
{
|
||||
if (l & 0xffff000000000000L)
|
||||
{
|
||||
if (l & 0xff00000000000000L)
|
||||
{
|
||||
return(bits[(int)(l>>56)]+56);
|
||||
}
|
||||
else return(bits[(int)(l>>48)]+48);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (l & 0x0000ff0000000000L)
|
||||
{
|
||||
return(bits[(int)(l>>40)]+40);
|
||||
}
|
||||
else return(bits[(int)(l>>32)]+32);
|
||||
}
|
||||
}
|
||||
else
|
||||
#else
|
||||
#ifdef SIXTY_FOUR_BIT
|
||||
if (l & 0xffffffff00000000LL)
|
||||
{
|
||||
if (l & 0xffff000000000000LL)
|
||||
{
|
||||
if (l & 0xff00000000000000LL)
|
||||
{
|
||||
return(bits[(int)(l>>56)]+56);
|
||||
}
|
||||
else return(bits[(int)(l>>48)]+48);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (l & 0x0000ff0000000000LL)
|
||||
{
|
||||
return(bits[(int)(l>>40)]+40);
|
||||
}
|
||||
else return(bits[(int)(l>>32)]+32);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
#if defined(THIRTY_TWO_BIT) || defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)
|
||||
if (l & 0xffff0000L)
|
||||
{
|
||||
if (l & 0xff000000L)
|
||||
return(bits[(int)(l>>24L)]+24);
|
||||
else return(bits[(int)(l>>16L)]+16);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#if defined(SIXTEEN_BIT) || defined(THIRTY_TWO_BIT) || defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)
|
||||
if (l & 0xff00L)
|
||||
return(bits[(int)(l>>8)]+8);
|
||||
else
|
||||
#endif
|
||||
return(bits[(int)(l )] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int BN_num_bits(const BIGNUM *a)
|
||||
{
|
||||
int i = a->top - 1;
|
||||
bn_check_top(a);
|
||||
|
||||
if (BN_is_zero(a)) return 0;
|
||||
return ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));
|
||||
}
|
||||
|
||||
void BN_clear_free(BIGNUM *a)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (a == NULL) return;
|
||||
bn_check_top(a);
|
||||
if (a->d != NULL)
|
||||
{
|
||||
OPENSSL_cleanse(a->d,a->dmax*sizeof(a->d[0]));
|
||||
if (!(BN_get_flags(a,BN_FLG_STATIC_DATA)))
|
||||
OPENSSL_free(a->d);
|
||||
}
|
||||
i=BN_get_flags(a,BN_FLG_MALLOCED);
|
||||
OPENSSL_cleanse(a,sizeof(BIGNUM));
|
||||
if (i)
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
void BN_free(BIGNUM *a)
|
||||
{
|
||||
if (a == NULL) return;
|
||||
bn_check_top(a);
|
||||
if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
|
||||
OPENSSL_free(a->d);
|
||||
if (a->flags & BN_FLG_MALLOCED)
|
||||
OPENSSL_free(a);
|
||||
else
|
||||
{
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
a->flags|=BN_FLG_FREE;
|
||||
#endif
|
||||
a->d = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void BN_init(BIGNUM *a)
|
||||
{
|
||||
memset(a,0,sizeof(BIGNUM));
|
||||
bn_check_top(a);
|
||||
}
|
||||
|
||||
BIGNUM *BN_new(void)
|
||||
{
|
||||
BIGNUM *ret;
|
||||
|
||||
if ((ret=(BIGNUM *)OPENSSL_malloc(sizeof(BIGNUM))) == NULL)
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BNerr(BN_F_BN_NEW,ERR_R_MALLOC_FAILURE);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
return(NULL);
|
||||
}
|
||||
ret->flags=BN_FLG_MALLOCED;
|
||||
ret->top=0;
|
||||
ret->neg=0;
|
||||
ret->dmax=0;
|
||||
ret->d=NULL;
|
||||
bn_check_top(ret);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/* This is used both by bn_expand2() and bn_dup_expand() */
|
||||
/* The caller MUST check that words > b->dmax before calling this */
|
||||
static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
|
||||
{
|
||||
BN_ULONG *A,*a = NULL;
|
||||
const BN_ULONG *B;
|
||||
int i;
|
||||
|
||||
bn_check_top(b);
|
||||
|
||||
if (words > (INT_MAX/(4*BN_BITS2)))
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BNerr(BN_F_BN_EXPAND_INTERNAL,BN_R_BIGNUM_TOO_LONG);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
return NULL;
|
||||
}
|
||||
if (BN_get_flags(b,BN_FLG_STATIC_DATA))
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BNerr(BN_F_BN_EXPAND_INTERNAL,BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
return(NULL);
|
||||
}
|
||||
a=A=(BN_ULONG *)OPENSSL_malloc(sizeof(BN_ULONG)*words);
|
||||
if (A == NULL)
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BNerr(BN_F_BN_EXPAND_INTERNAL,ERR_R_MALLOC_FAILURE);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
return(NULL);
|
||||
}
|
||||
#if 1
|
||||
B=b->d;
|
||||
/* Check if the previous number needs to be copied */
|
||||
if (B != NULL)
|
||||
{
|
||||
for (i=b->top>>2; i>0; i--,A+=4,B+=4)
|
||||
{
|
||||
/*
|
||||
* The fact that the loop is unrolled
|
||||
* 4-wise is a tribute to Intel. It's
|
||||
* the one that doesn't have enough
|
||||
* registers to accomodate more data.
|
||||
* I'd unroll it 8-wise otherwise:-)
|
||||
*
|
||||
* <appro@fy.chalmers.se>
|
||||
*/
|
||||
BN_ULONG a0,a1,a2,a3;
|
||||
a0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];
|
||||
A[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;
|
||||
}
|
||||
switch (b->top&3)
|
||||
{
|
||||
case 3: A[2]=B[2];
|
||||
case 2: A[1]=B[1];
|
||||
case 1: A[0]=B[0];
|
||||
case 0: /* workaround for ultrix cc: without 'case 0', the optimizer does
|
||||
* the switch table by doing a=top&3; a--; goto jump_table[a];
|
||||
* which fails for top== 0 */
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
memset(A,0,sizeof(BN_ULONG)*words);
|
||||
memcpy(A,b->d,sizeof(b->d[0])*b->top);
|
||||
#endif
|
||||
|
||||
return(a);
|
||||
}
|
||||
|
||||
/* This is an internal function that can be used instead of bn_expand2()
|
||||
* when there is a need to copy BIGNUMs instead of only expanding the
|
||||
* data part, while still expanding them.
|
||||
* Especially useful when needing to expand BIGNUMs that are declared
|
||||
* 'const' and should therefore not be changed.
|
||||
* The reason to use this instead of a BN_dup() followed by a bn_expand2()
|
||||
* is memory allocation overhead. A BN_dup() followed by a bn_expand2()
|
||||
* will allocate new memory for the BIGNUM data twice, and free it once,
|
||||
* while bn_dup_expand() makes sure allocation is made only once.
|
||||
*/
|
||||
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
BIGNUM *bn_dup_expand(const BIGNUM *b, int words)
|
||||
{
|
||||
BIGNUM *r = NULL;
|
||||
|
||||
bn_check_top(b);
|
||||
|
||||
/* This function does not work if
|
||||
* words <= b->dmax && top < words
|
||||
* because BN_dup() does not preserve 'dmax'!
|
||||
* (But bn_dup_expand() is not used anywhere yet.)
|
||||
*/
|
||||
|
||||
if (words > b->dmax)
|
||||
{
|
||||
BN_ULONG *a = bn_expand_internal(b, words);
|
||||
|
||||
if (a)
|
||||
{
|
||||
r = BN_new();
|
||||
if (r)
|
||||
{
|
||||
r->top = b->top;
|
||||
r->dmax = words;
|
||||
r->neg = b->neg;
|
||||
r->d = a;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* r == NULL, BN_new failure */
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
}
|
||||
/* If a == NULL, there was an error in allocation in
|
||||
bn_expand_internal(), and NULL should be returned */
|
||||
}
|
||||
else
|
||||
{
|
||||
r = BN_dup(b);
|
||||
}
|
||||
|
||||
bn_check_top(r);
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This is an internal function that should not be used in applications.
|
||||
* It ensures that 'b' has enough room for a 'words' word number
|
||||
* and initialises any unused part of b->d with leading zeros.
|
||||
* It is mostly used by the various BIGNUM routines. If there is an error,
|
||||
* NULL is returned. If not, 'b' is returned. */
|
||||
|
||||
BIGNUM *bn_expand2(BIGNUM *b, int words)
|
||||
{
|
||||
bn_check_top(b);
|
||||
|
||||
if (words > b->dmax)
|
||||
{
|
||||
BN_ULONG *a = bn_expand_internal(b, words);
|
||||
if(!a) return NULL;
|
||||
if(b->d) OPENSSL_free(b->d);
|
||||
b->d=a;
|
||||
b->dmax=words;
|
||||
}
|
||||
|
||||
/* None of this should be necessary because of what b->top means! */
|
||||
#if 0
|
||||
/* NB: bn_wexpand() calls this only if the BIGNUM really has to grow */
|
||||
if (b->top < b->dmax)
|
||||
{
|
||||
int i;
|
||||
BN_ULONG *A = &(b->d[b->top]);
|
||||
for (i=(b->dmax - b->top)>>3; i>0; i--,A+=8)
|
||||
{
|
||||
A[0]=0; A[1]=0; A[2]=0; A[3]=0;
|
||||
A[4]=0; A[5]=0; A[6]=0; A[7]=0;
|
||||
}
|
||||
for (i=(b->dmax - b->top)&7; i>0; i--,A++)
|
||||
A[0]=0;
|
||||
assert(A == &(b->d[b->dmax]));
|
||||
}
|
||||
#endif
|
||||
bn_check_top(b);
|
||||
return b;
|
||||
}
|
||||
|
||||
BIGNUM *BN_dup(const BIGNUM *a)
|
||||
{
|
||||
BIGNUM *t;
|
||||
|
||||
if (a == NULL) return NULL;
|
||||
bn_check_top(a);
|
||||
|
||||
t = BN_new();
|
||||
if (t == NULL) return NULL;
|
||||
if(!BN_copy(t, a))
|
||||
{
|
||||
BN_free(t);
|
||||
return NULL;
|
||||
}
|
||||
bn_check_top(t);
|
||||
return t;
|
||||
}
|
||||
|
||||
BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
|
||||
{
|
||||
int i;
|
||||
BN_ULONG *A;
|
||||
const BN_ULONG *B;
|
||||
|
||||
bn_check_top(b);
|
||||
|
||||
if (a == b) return(a);
|
||||
if (bn_wexpand(a,b->top) == NULL) return(NULL);
|
||||
|
||||
#if 1
|
||||
A=a->d;
|
||||
B=b->d;
|
||||
for (i=b->top>>2; i>0; i--,A+=4,B+=4)
|
||||
{
|
||||
BN_ULONG a0,a1,a2,a3;
|
||||
a0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];
|
||||
A[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;
|
||||
}
|
||||
switch (b->top&3)
|
||||
{
|
||||
case 3: A[2]=B[2];
|
||||
case 2: A[1]=B[1];
|
||||
case 1: A[0]=B[0];
|
||||
case 0: ; /* ultrix cc workaround, see comments in bn_expand_internal */
|
||||
}
|
||||
#else
|
||||
memcpy(a->d,b->d,sizeof(b->d[0])*b->top);
|
||||
#endif
|
||||
|
||||
a->top=b->top;
|
||||
a->neg=b->neg;
|
||||
bn_check_top(a);
|
||||
return(a);
|
||||
}
|
||||
|
||||
void BN_swap(BIGNUM *a, BIGNUM *b)
|
||||
{
|
||||
int flags_old_a, flags_old_b;
|
||||
BN_ULONG *tmp_d;
|
||||
int tmp_top, tmp_dmax, tmp_neg;
|
||||
|
||||
bn_check_top(a);
|
||||
bn_check_top(b);
|
||||
|
||||
flags_old_a = a->flags;
|
||||
flags_old_b = b->flags;
|
||||
|
||||
tmp_d = a->d;
|
||||
tmp_top = a->top;
|
||||
tmp_dmax = a->dmax;
|
||||
tmp_neg = a->neg;
|
||||
|
||||
a->d = b->d;
|
||||
a->top = b->top;
|
||||
a->dmax = b->dmax;
|
||||
a->neg = b->neg;
|
||||
|
||||
b->d = tmp_d;
|
||||
b->top = tmp_top;
|
||||
b->dmax = tmp_dmax;
|
||||
b->neg = tmp_neg;
|
||||
|
||||
a->flags = (flags_old_a & BN_FLG_MALLOCED) | (flags_old_b & BN_FLG_STATIC_DATA);
|
||||
b->flags = (flags_old_b & BN_FLG_MALLOCED) | (flags_old_a & BN_FLG_STATIC_DATA);
|
||||
bn_check_top(a);
|
||||
bn_check_top(b);
|
||||
}
|
||||
|
||||
void BN_clear(BIGNUM *a)
|
||||
{
|
||||
bn_check_top(a);
|
||||
if (a->d != NULL)
|
||||
memset(a->d,0,a->dmax*sizeof(a->d[0]));
|
||||
a->top=0;
|
||||
a->neg=0;
|
||||
}
|
||||
|
||||
BN_ULONG BN_get_word(const BIGNUM *a)
|
||||
{
|
||||
if (a->top > 1)
|
||||
return BN_MASK2;
|
||||
else if (a->top == 1)
|
||||
return a->d[0];
|
||||
/* a->top == 0 */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BN_set_word(BIGNUM *a, BN_ULONG w)
|
||||
{
|
||||
bn_check_top(a);
|
||||
if (bn_expand(a,(int)sizeof(BN_ULONG)*8) == NULL) return(0);
|
||||
a->neg = 0;
|
||||
a->d[0] = w;
|
||||
a->top = (w ? 1 : 0);
|
||||
bn_check_top(a);
|
||||
return(1);
|
||||
}
|
||||
|
||||
BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
|
||||
{
|
||||
unsigned int i,m;
|
||||
unsigned int n;
|
||||
BN_ULONG l;
|
||||
BIGNUM *bn = NULL;
|
||||
|
||||
if (ret == NULL)
|
||||
ret = bn = BN_new();
|
||||
if (ret == NULL) return(NULL);
|
||||
bn_check_top(ret);
|
||||
l=0;
|
||||
n=len;
|
||||
if (n == 0)
|
||||
{
|
||||
ret->top=0;
|
||||
return(ret);
|
||||
}
|
||||
i=((n-1)/BN_BYTES)+1;
|
||||
m=((n-1)%(BN_BYTES));
|
||||
if (bn_wexpand(ret, (int)i) == NULL)
|
||||
{
|
||||
if (bn) BN_free(bn);
|
||||
return NULL;
|
||||
}
|
||||
ret->top=i;
|
||||
ret->neg=0;
|
||||
while (n--)
|
||||
{
|
||||
l=(l<<8L)| *(s++);
|
||||
if (m-- == 0)
|
||||
{
|
||||
ret->d[--i]=l;
|
||||
l=0;
|
||||
m=BN_BYTES-1;
|
||||
}
|
||||
}
|
||||
/* need to call this due to clear byte at top if avoiding
|
||||
* having the top bit set (-ve number) */
|
||||
bn_correct_top(ret);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/* ignore negative */
|
||||
int BN_bn2bin(const BIGNUM *a, unsigned char *to)
|
||||
{
|
||||
int n,i;
|
||||
BN_ULONG l;
|
||||
|
||||
bn_check_top(a);
|
||||
n=i=BN_num_bytes(a);
|
||||
while (i--)
|
||||
{
|
||||
l=a->d[i/BN_BYTES];
|
||||
*(to++)=(unsigned char)(l>>(8*(i%BN_BYTES)))&0xff;
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
int BN_ucmp(const BIGNUM *a, const BIGNUM *b)
|
||||
{
|
||||
int i;
|
||||
BN_ULONG t1,t2,*ap,*bp;
|
||||
|
||||
bn_check_top(a);
|
||||
bn_check_top(b);
|
||||
|
||||
i=a->top-b->top;
|
||||
if (i != 0) return(i);
|
||||
ap=a->d;
|
||||
bp=b->d;
|
||||
for (i=a->top-1; i>=0; i--)
|
||||
{
|
||||
t1= ap[i];
|
||||
t2= bp[i];
|
||||
if (t1 != t2)
|
||||
return((t1 > t2) ? 1 : -1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
int BN_cmp(const BIGNUM *a, const BIGNUM *b)
|
||||
{
|
||||
int i;
|
||||
int gt,lt;
|
||||
BN_ULONG t1,t2;
|
||||
|
||||
if ((a == NULL) || (b == NULL))
|
||||
{
|
||||
if (a != NULL)
|
||||
return(-1);
|
||||
else if (b != NULL)
|
||||
return(1);
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
|
||||
bn_check_top(a);
|
||||
bn_check_top(b);
|
||||
|
||||
if (a->neg != b->neg)
|
||||
{
|
||||
if (a->neg)
|
||||
return(-1);
|
||||
else return(1);
|
||||
}
|
||||
if (a->neg == 0)
|
||||
{ gt=1; lt= -1; }
|
||||
else { gt= -1; lt=1; }
|
||||
|
||||
if (a->top > b->top) return(gt);
|
||||
if (a->top < b->top) return(lt);
|
||||
for (i=a->top-1; i>=0; i--)
|
||||
{
|
||||
t1=a->d[i];
|
||||
t2=b->d[i];
|
||||
if (t1 > t2) return(gt);
|
||||
if (t1 < t2) return(lt);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
int BN_set_bit(BIGNUM *a, int n)
|
||||
{
|
||||
int i,j,k;
|
||||
|
||||
if (n < 0)
|
||||
return 0;
|
||||
|
||||
i=n/BN_BITS2;
|
||||
j=n%BN_BITS2;
|
||||
if (a->top <= i)
|
||||
{
|
||||
if (bn_wexpand(a,i+1) == NULL) return(0);
|
||||
for(k=a->top; k<i+1; k++)
|
||||
a->d[k]=0;
|
||||
a->top=i+1;
|
||||
}
|
||||
|
||||
a->d[i]|=(((BN_ULONG)1)<<j);
|
||||
bn_check_top(a);
|
||||
return(1);
|
||||
}
|
||||
|
||||
int BN_clear_bit(BIGNUM *a, int n)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
bn_check_top(a);
|
||||
if (n < 0) return 0;
|
||||
|
||||
i=n/BN_BITS2;
|
||||
j=n%BN_BITS2;
|
||||
if (a->top <= i) return(0);
|
||||
|
||||
a->d[i]&=(~(((BN_ULONG)1)<<j));
|
||||
bn_correct_top(a);
|
||||
return(1);
|
||||
}
|
||||
|
||||
int BN_is_bit_set(const BIGNUM *a, int n)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
bn_check_top(a);
|
||||
if (n < 0) return 0;
|
||||
i=n/BN_BITS2;
|
||||
j=n%BN_BITS2;
|
||||
if (a->top <= i) return 0;
|
||||
return((a->d[i]&(((BN_ULONG)1)<<j))?1:0);
|
||||
}
|
||||
|
||||
int BN_mask_bits(BIGNUM *a, int n)
|
||||
{
|
||||
int b,w;
|
||||
|
||||
bn_check_top(a);
|
||||
if (n < 0) return 0;
|
||||
|
||||
w=n/BN_BITS2;
|
||||
b=n%BN_BITS2;
|
||||
if (w >= a->top) return 0;
|
||||
if (b == 0)
|
||||
a->top=w;
|
||||
else
|
||||
{
|
||||
a->top=w+1;
|
||||
a->d[w]&= ~(BN_MASK2<<b);
|
||||
}
|
||||
bn_correct_top(a);
|
||||
return(1);
|
||||
}
|
||||
|
||||
void BN_set_negative(BIGNUM *a, int b)
|
||||
{
|
||||
if (b && !BN_is_zero(a))
|
||||
a->neg = 1;
|
||||
else
|
||||
a->neg = 0;
|
||||
}
|
||||
|
||||
int bn_cmp_words(const BN_ULONG *a, const BN_ULONG *b, int n)
|
||||
{
|
||||
int i;
|
||||
BN_ULONG aa,bb;
|
||||
|
||||
aa=a[n-1];
|
||||
bb=b[n-1];
|
||||
if (aa != bb) return((aa > bb)?1:-1);
|
||||
for (i=n-2; i>=0; i--)
|
||||
{
|
||||
aa=a[i];
|
||||
bb=b[i];
|
||||
if (aa != bb) return((aa > bb)?1:-1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Here follows a specialised variants of bn_cmp_words(). It has the
|
||||
property of performing the operation on arrays of different sizes.
|
||||
The sizes of those arrays is expressed through cl, which is the
|
||||
common length ( basicall, min(len(a),len(b)) ), and dl, which is the
|
||||
delta between the two lengths, calculated as len(a)-len(b).
|
||||
All lengths are the number of BN_ULONGs... */
|
||||
|
||||
int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b,
|
||||
int cl, int dl)
|
||||
{
|
||||
int n,i;
|
||||
n = cl-1;
|
||||
|
||||
if (dl < 0)
|
||||
{
|
||||
for (i=dl; i<0; i++)
|
||||
{
|
||||
if (b[n-i] != 0)
|
||||
return -1; /* a < b */
|
||||
}
|
||||
}
|
||||
if (dl > 0)
|
||||
{
|
||||
for (i=dl; i>0; i--)
|
||||
{
|
||||
if (a[n+i] != 0)
|
||||
return 1; /* a > b */
|
||||
}
|
||||
}
|
||||
return bn_cmp_words(a,b,cl);
|
||||
}
|
305
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_mod.c
Executable file
305
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_mod.c
Executable file
@ -0,0 +1,305 @@
|
||||
/* crypto/bn/bn_mod.c */
|
||||
/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
|
||||
* for the OpenSSL project. */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2000 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).
|
||||
*
|
||||
*/
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
|
||||
#if 0 /* now just a #define */
|
||||
int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
|
||||
{
|
||||
return(BN_div(NULL,rem,m,d,ctx));
|
||||
/* note that rem->neg == m->neg (unless the remainder is zero) */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
|
||||
{
|
||||
/* like BN_mod, but returns non-negative remainder
|
||||
* (i.e., 0 <= r < |d| always holds) */
|
||||
|
||||
if (!(BN_mod(r,m,d,ctx)))
|
||||
return 0;
|
||||
if (!r->neg)
|
||||
return 1;
|
||||
/* now -|d| < r < 0, so we have to set r := r + |d| */
|
||||
return (d->neg ? BN_sub : BN_add)(r, r, d);
|
||||
}
|
||||
|
||||
|
||||
int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
|
||||
{
|
||||
if (!BN_add(r, a, b)) return 0;
|
||||
return BN_nnmod(r, r, m, ctx);
|
||||
}
|
||||
|
||||
|
||||
/* BN_mod_add variant that may be used if both a and b are non-negative
|
||||
* and less than m */
|
||||
int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m)
|
||||
{
|
||||
if (!BN_uadd(r, a, b)) return 0;
|
||||
if (BN_ucmp(r, m) >= 0)
|
||||
return BN_usub(r, r, m);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
|
||||
{
|
||||
if (!BN_sub(r, a, b)) return 0;
|
||||
return BN_nnmod(r, r, m, ctx);
|
||||
}
|
||||
|
||||
|
||||
/* BN_mod_sub variant that may be used if both a and b are non-negative
|
||||
* and less than m */
|
||||
int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m)
|
||||
{
|
||||
if (!BN_sub(r, a, b)) return 0;
|
||||
if (r->neg)
|
||||
return BN_add(r, r, m);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* slow but works */
|
||||
int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM *t;
|
||||
int ret=0;
|
||||
|
||||
bn_check_top(a);
|
||||
bn_check_top(b);
|
||||
bn_check_top(m);
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
if ((t = BN_CTX_get(ctx)) == NULL) goto err;
|
||||
if (a == b)
|
||||
{ if (!BN_sqr(t,a,ctx)) goto err; }
|
||||
else
|
||||
{ if (!BN_mul(t,a,b,ctx)) goto err; }
|
||||
if (!BN_nnmod(r,t,m,ctx)) goto err;
|
||||
bn_check_top(r);
|
||||
ret=1;
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)
|
||||
{
|
||||
if (!BN_sqr(r, a, ctx)) return 0;
|
||||
/* r->neg == 0, thus we don't need BN_nnmod */
|
||||
return BN_mod(r, r, m, ctx);
|
||||
}
|
||||
|
||||
|
||||
int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)
|
||||
{
|
||||
if (!BN_lshift1(r, a)) return 0;
|
||||
bn_check_top(r);
|
||||
return BN_nnmod(r, r, m, ctx);
|
||||
}
|
||||
|
||||
|
||||
/* BN_mod_lshift1 variant that may be used if a is non-negative
|
||||
* and less than m */
|
||||
int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m)
|
||||
{
|
||||
if (!BN_lshift1(r, a)) return 0;
|
||||
bn_check_top(r);
|
||||
if (BN_cmp(r, m) >= 0)
|
||||
return BN_sub(r, r, m);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM *abs_m = NULL;
|
||||
int ret;
|
||||
|
||||
if (!BN_nnmod(r, a, m, ctx)) return 0;
|
||||
|
||||
if (m->neg)
|
||||
{
|
||||
abs_m = BN_dup(m);
|
||||
if (abs_m == NULL) return 0;
|
||||
abs_m->neg = 0;
|
||||
}
|
||||
|
||||
ret = BN_mod_lshift_quick(r, r, n, (abs_m ? abs_m : m));
|
||||
bn_check_top(r);
|
||||
|
||||
if (abs_m)
|
||||
BN_free(abs_m);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* BN_mod_lshift variant that may be used if a is non-negative
|
||||
* and less than m */
|
||||
int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m)
|
||||
{
|
||||
if (r != a)
|
||||
{
|
||||
if (BN_copy(r, a) == NULL) return 0;
|
||||
}
|
||||
|
||||
while (n > 0)
|
||||
{
|
||||
int max_shift;
|
||||
|
||||
/* 0 < r < m */
|
||||
max_shift = BN_num_bits(m) - BN_num_bits(r);
|
||||
/* max_shift >= 0 */
|
||||
|
||||
if (max_shift < 0)
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BNerr(BN_F_BN_MOD_LSHIFT_QUICK, BN_R_INPUT_NOT_REDUCED);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (max_shift > n)
|
||||
max_shift = n;
|
||||
|
||||
if (max_shift)
|
||||
{
|
||||
if (!BN_lshift(r, r, max_shift)) return 0;
|
||||
n -= max_shift;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!BN_lshift1(r, r)) return 0;
|
||||
--n;
|
||||
}
|
||||
|
||||
/* BN_num_bits(r) <= BN_num_bits(m) */
|
||||
|
||||
if (BN_cmp(r, m) >= 0)
|
||||
{
|
||||
if (!BN_sub(r, r, m)) return 0;
|
||||
}
|
||||
}
|
||||
bn_check_top(r);
|
||||
|
||||
return 1;
|
||||
}
|
370
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_mont.c
Executable file
370
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_mont.c
Executable file
@ -0,0 +1,370 @@
|
||||
/* crypto/bn/bn_mont.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/*
|
||||
* Details about Montgomery multiplication algorithms can be found at
|
||||
* http://security.ece.orst.edu/publications.html, e.g.
|
||||
* http://security.ece.orst.edu/koc/papers/j37acmon.pdf and
|
||||
* sections 3.8 and 4.2 in http://security.ece.orst.edu/koc/papers/r01rsasw.pdf
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
#define MONT_WORD /* use the faster word-based algorithm */
|
||||
|
||||
int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
BN_MONT_CTX *mont, BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM *tmp;
|
||||
int ret=0;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
tmp = BN_CTX_get(ctx);
|
||||
if (tmp == NULL) goto err;
|
||||
|
||||
bn_check_top(tmp);
|
||||
if (a == b)
|
||||
{
|
||||
if (!BN_sqr(tmp,a,ctx)) goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!BN_mul(tmp,a,b,ctx)) goto err;
|
||||
}
|
||||
/* reduce from aRR to aR */
|
||||
if (!BN_from_montgomery(r,tmp,mont,ctx)) goto err;
|
||||
bn_check_top(r);
|
||||
ret=1;
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
int BN_from_montgomery(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
int retn=0;
|
||||
|
||||
#ifdef MONT_WORD
|
||||
BIGNUM *n,*r;
|
||||
BN_ULONG *ap,*np,*rp,n0,v,*nrp;
|
||||
int al,nl,max,i,x,ri;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
if ((r = BN_CTX_get(ctx)) == NULL) goto err;
|
||||
|
||||
if (!BN_copy(r,a)) goto err;
|
||||
n= &(mont->N);
|
||||
|
||||
ap=a->d;
|
||||
/* mont->ri is the size of mont->N in bits (rounded up
|
||||
to the word size) */
|
||||
al=ri=mont->ri/BN_BITS2;
|
||||
|
||||
nl=n->top;
|
||||
if ((al == 0) || (nl == 0)) { r->top=0; return(1); }
|
||||
|
||||
max=(nl+al+1); /* allow for overflow (no?) XXX */
|
||||
if (bn_wexpand(r,max) == NULL) goto err;
|
||||
if (bn_wexpand(ret,max) == NULL) goto err;
|
||||
|
||||
r->neg=a->neg^n->neg;
|
||||
np=n->d;
|
||||
rp=r->d;
|
||||
nrp= &(r->d[nl]);
|
||||
|
||||
/* clear the top words of T */
|
||||
#if 1
|
||||
for (i=r->top; i<max; i++) /* memset? XXX */
|
||||
r->d[i]=0;
|
||||
#else
|
||||
memset(&(r->d[r->top]),0,(max-r->top)*sizeof(BN_ULONG));
|
||||
#endif
|
||||
|
||||
r->top=max;
|
||||
n0=mont->n0;
|
||||
|
||||
#ifdef BN_COUNT
|
||||
fprintf(stderr,"word BN_from_montgomery %d * %d\n",nl,nl);
|
||||
#endif
|
||||
for (i=0; i<nl; i++)
|
||||
{
|
||||
#ifdef __TANDEM
|
||||
{
|
||||
long long t1;
|
||||
long long t2;
|
||||
long long t3;
|
||||
t1 = rp[0] * (n0 & 0177777);
|
||||
t2 = 037777600000l;
|
||||
t2 = n0 & t2;
|
||||
t3 = rp[0] & 0177777;
|
||||
t2 = (t3 * t2) & BN_MASK2;
|
||||
t1 = t1 + t2;
|
||||
v=bn_mul_add_words(rp,np,nl,(BN_ULONG) t1);
|
||||
}
|
||||
#else
|
||||
v=bn_mul_add_words(rp,np,nl,(rp[0]*n0)&BN_MASK2);
|
||||
#endif
|
||||
nrp++;
|
||||
rp++;
|
||||
if (((nrp[-1]+=v)&BN_MASK2) >= v)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
if (((++nrp[0])&BN_MASK2) != 0) continue;
|
||||
if (((++nrp[1])&BN_MASK2) != 0) continue;
|
||||
for (x=2; (((++nrp[x])&BN_MASK2) == 0); x++) ;
|
||||
}
|
||||
}
|
||||
bn_correct_top(r);
|
||||
|
||||
/* mont->ri will be a multiple of the word size */
|
||||
#if 0
|
||||
BN_rshift(ret,r,mont->ri);
|
||||
#else
|
||||
ret->neg = r->neg;
|
||||
x=ri;
|
||||
rp=ret->d;
|
||||
ap= &(r->d[x]);
|
||||
if (r->top < x)
|
||||
al=0;
|
||||
else
|
||||
al=r->top-x;
|
||||
ret->top=al;
|
||||
al-=4;
|
||||
for (i=0; i<al; i+=4)
|
||||
{
|
||||
BN_ULONG t1,t2,t3,t4;
|
||||
|
||||
t1=ap[i+0];
|
||||
t2=ap[i+1];
|
||||
t3=ap[i+2];
|
||||
t4=ap[i+3];
|
||||
rp[i+0]=t1;
|
||||
rp[i+1]=t2;
|
||||
rp[i+2]=t3;
|
||||
rp[i+3]=t4;
|
||||
}
|
||||
al+=4;
|
||||
for (; i<al; i++)
|
||||
rp[i]=ap[i];
|
||||
#endif
|
||||
#else /* !MONT_WORD */
|
||||
BIGNUM *t1,*t2;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
t1 = BN_CTX_get(ctx);
|
||||
t2 = BN_CTX_get(ctx);
|
||||
if (t1 == NULL || t2 == NULL) goto err;
|
||||
|
||||
if (!BN_copy(t1,a)) goto err;
|
||||
BN_mask_bits(t1,mont->ri);
|
||||
|
||||
if (!BN_mul(t2,t1,&mont->Ni,ctx)) goto err;
|
||||
BN_mask_bits(t2,mont->ri);
|
||||
|
||||
if (!BN_mul(t1,t2,&mont->N,ctx)) goto err;
|
||||
if (!BN_add(t2,a,t1)) goto err;
|
||||
if (!BN_rshift(ret,t2,mont->ri)) goto err;
|
||||
#endif /* MONT_WORD */
|
||||
|
||||
if (BN_ucmp(ret, &(mont->N)) >= 0)
|
||||
{
|
||||
if (!BN_usub(ret,ret,&(mont->N))) goto err;
|
||||
}
|
||||
retn=1;
|
||||
bn_check_top(ret);
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
return(retn);
|
||||
}
|
||||
|
||||
BN_MONT_CTX *BN_MONT_CTX_new(void)
|
||||
{
|
||||
BN_MONT_CTX *ret;
|
||||
|
||||
if ((ret=(BN_MONT_CTX *)OPENSSL_malloc(sizeof(BN_MONT_CTX))) == NULL)
|
||||
return(NULL);
|
||||
|
||||
BN_MONT_CTX_init(ret);
|
||||
ret->flags=BN_FLG_MALLOCED;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
|
||||
{
|
||||
ctx->ri=0;
|
||||
BN_init(&(ctx->RR));
|
||||
BN_init(&(ctx->N));
|
||||
BN_init(&(ctx->Ni));
|
||||
ctx->flags=0;
|
||||
}
|
||||
|
||||
void BN_MONT_CTX_free(BN_MONT_CTX *mont)
|
||||
{
|
||||
if(mont == NULL)
|
||||
return;
|
||||
|
||||
BN_free(&(mont->RR));
|
||||
BN_free(&(mont->N));
|
||||
BN_free(&(mont->Ni));
|
||||
if (mont->flags & BN_FLG_MALLOCED)
|
||||
OPENSSL_free(mont);
|
||||
}
|
||||
|
||||
int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
|
||||
{
|
||||
int ret = 0;
|
||||
BIGNUM *Ri,*R;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
if((Ri = BN_CTX_get(ctx)) == NULL) goto err;
|
||||
R= &(mont->RR); /* grab RR as a temp */
|
||||
if (!BN_copy(&(mont->N),mod)) goto err; /* Set N */
|
||||
mont->N.neg = 0;
|
||||
|
||||
#ifdef MONT_WORD
|
||||
{
|
||||
BIGNUM tmod;
|
||||
BN_ULONG buf[2];
|
||||
|
||||
mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2;
|
||||
BN_zero(R);
|
||||
if (!(BN_set_bit(R,BN_BITS2))) goto err; /* R */
|
||||
|
||||
buf[0]=mod->d[0]; /* tmod = N mod word size */
|
||||
buf[1]=0;
|
||||
tmod.d=buf;
|
||||
tmod.top = buf[0] != 0 ? 1 : 0;
|
||||
tmod.dmax=2;
|
||||
tmod.neg=0;
|
||||
/* Ri = R^-1 mod N*/
|
||||
if ((BN_mod_inverse(Ri,R,&tmod,ctx)) == NULL)
|
||||
goto err;
|
||||
if (!BN_lshift(Ri,Ri,BN_BITS2)) goto err; /* R*Ri */
|
||||
if (!BN_is_zero(Ri))
|
||||
{
|
||||
if (!BN_sub_word(Ri,1)) goto err;
|
||||
}
|
||||
else /* if N mod word size == 1 */
|
||||
{
|
||||
if (!BN_set_word(Ri,BN_MASK2)) goto err; /* Ri-- (mod word size) */
|
||||
}
|
||||
if (!BN_div(Ri,NULL,Ri,&tmod,ctx)) goto err;
|
||||
/* Ni = (R*Ri-1)/N,
|
||||
* keep only least significant word: */
|
||||
mont->n0 = (Ri->top > 0) ? Ri->d[0] : 0;
|
||||
}
|
||||
#else /* !MONT_WORD */
|
||||
{ /* bignum version */
|
||||
mont->ri=BN_num_bits(&mont->N);
|
||||
BN_zero(R);
|
||||
if (!BN_set_bit(R,mont->ri)) goto err; /* R = 2^ri */
|
||||
/* Ri = R^-1 mod N*/
|
||||
if ((BN_mod_inverse(Ri,R,&mont->N,ctx)) == NULL)
|
||||
goto err;
|
||||
if (!BN_lshift(Ri,Ri,mont->ri)) goto err; /* R*Ri */
|
||||
if (!BN_sub_word(Ri,1)) goto err;
|
||||
/* Ni = (R*Ri-1) / N */
|
||||
if (!BN_div(&(mont->Ni),NULL,Ri,&mont->N,ctx)) goto err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* setup RR for conversions */
|
||||
BN_zero(&(mont->RR));
|
||||
if (!BN_set_bit(&(mont->RR),mont->ri*2)) goto err;
|
||||
if (!BN_mod(&(mont->RR),&(mont->RR),&(mont->N),ctx)) goto err;
|
||||
|
||||
ret = 1;
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from)
|
||||
{
|
||||
if (to == from) return(to);
|
||||
|
||||
if (!BN_copy(&(to->RR),&(from->RR))) return NULL;
|
||||
if (!BN_copy(&(to->N),&(from->N))) return NULL;
|
||||
if (!BN_copy(&(to->Ni),&(from->Ni))) return NULL;
|
||||
to->ri=from->ri;
|
||||
to->n0=from->n0;
|
||||
return(to);
|
||||
}
|
||||
|
||||
BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,
|
||||
const BIGNUM *mod, BN_CTX *ctx)
|
||||
{
|
||||
if (*pmont)
|
||||
return *pmont;
|
||||
CRYPTO_w_lock(lock);
|
||||
if (!*pmont)
|
||||
{
|
||||
BN_MONT_CTX *mtmp;
|
||||
mtmp = BN_MONT_CTX_new();
|
||||
if (mtmp && !BN_MONT_CTX_set(mtmp, mod, ctx))
|
||||
BN_MONT_CTX_free(mtmp);
|
||||
else
|
||||
*pmont = mtmp;
|
||||
}
|
||||
CRYPTO_w_unlock(lock);
|
||||
return *pmont;
|
||||
}
|
1164
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_mul.c
Executable file
1164
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_mul.c
Executable file
File diff suppressed because it is too large
Load Diff
497
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_prime.c
Executable file
497
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_prime.c
Executable file
@ -0,0 +1,497 @@
|
||||
/* crypto/bn/bn_prime.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2001 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).
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
#include <openssl/rand.h>
|
||||
|
||||
/* NB: these functions have been "upgraded", the deprecated versions (which are
|
||||
* compatibility wrappers using these functions) are in bn_depr.c.
|
||||
* - Geoff
|
||||
*/
|
||||
|
||||
/* The quick sieve algorithm approach to weeding out primes is
|
||||
* Philip Zimmermann's, as implemented in PGP. I have had a read of
|
||||
* his comments and implemented my own version.
|
||||
*/
|
||||
#include "bn_prime.h"
|
||||
|
||||
static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1,
|
||||
const BIGNUM *a1_odd, int k, BN_CTX *ctx, BN_MONT_CTX *mont);
|
||||
static int probable_prime(BIGNUM *rnd, int bits);
|
||||
static int probable_prime_dh(BIGNUM *rnd, int bits,
|
||||
const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx);
|
||||
static int probable_prime_dh_safe(BIGNUM *rnd, int bits,
|
||||
const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx);
|
||||
|
||||
int BN_GENCB_call(BN_GENCB *cb, int a, int b)
|
||||
{
|
||||
/* No callback means continue */
|
||||
if(!cb) return 1;
|
||||
switch(cb->ver)
|
||||
{
|
||||
case 1:
|
||||
/* Deprecated-style callbacks */
|
||||
if(!cb->cb.cb_1)
|
||||
return 1;
|
||||
cb->cb.cb_1(a, b, cb->arg);
|
||||
return 1;
|
||||
case 2:
|
||||
/* New-style callbacks */
|
||||
return cb->cb.cb_2(a, b, cb);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/* Unrecognised callback type */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
|
||||
const BIGNUM *add, const BIGNUM *rem, BN_GENCB *cb)
|
||||
{
|
||||
BIGNUM *t;
|
||||
int found=0;
|
||||
int i,j,c1=0;
|
||||
BN_CTX *ctx;
|
||||
int checks = BN_prime_checks_for_size(bits);
|
||||
|
||||
ctx=BN_CTX_new();
|
||||
if (ctx == NULL) goto err;
|
||||
BN_CTX_start(ctx);
|
||||
t = BN_CTX_get(ctx);
|
||||
if(!t) goto err;
|
||||
loop:
|
||||
/* make a random number and set the top and bottom bits */
|
||||
if (add == NULL)
|
||||
{
|
||||
if (!probable_prime(ret,bits)) goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (safe)
|
||||
{
|
||||
if (!probable_prime_dh_safe(ret,bits,add,rem,ctx))
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!probable_prime_dh(ret,bits,add,rem,ctx))
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
/* if (BN_mod_word(ret,(BN_ULONG)3) == 1) goto loop; */
|
||||
if(!BN_GENCB_call(cb, 0, c1++))
|
||||
/* aborted */
|
||||
goto err;
|
||||
|
||||
if (!safe)
|
||||
{
|
||||
i=BN_is_prime_fasttest_ex(ret,checks,ctx,0,cb);
|
||||
if (i == -1) goto err;
|
||||
if (i == 0) goto loop;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* for "safe prime" generation,
|
||||
* check that (p-1)/2 is prime.
|
||||
* Since a prime is odd, We just
|
||||
* need to divide by 2 */
|
||||
if (!BN_rshift1(t,ret)) goto err;
|
||||
|
||||
for (i=0; i<checks; i++)
|
||||
{
|
||||
j=BN_is_prime_fasttest_ex(ret,1,ctx,0,cb);
|
||||
if (j == -1) goto err;
|
||||
if (j == 0) goto loop;
|
||||
|
||||
j=BN_is_prime_fasttest_ex(t,1,ctx,0,cb);
|
||||
if (j == -1) goto err;
|
||||
if (j == 0) goto loop;
|
||||
|
||||
if(!BN_GENCB_call(cb, 2, c1-1))
|
||||
goto err;
|
||||
/* We have a safe prime test pass */
|
||||
}
|
||||
}
|
||||
/* we have a prime :-) */
|
||||
found = 1;
|
||||
err:
|
||||
if (ctx != NULL)
|
||||
{
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx);
|
||||
}
|
||||
bn_check_top(ret);
|
||||
return found;
|
||||
}
|
||||
|
||||
int BN_is_prime_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, BN_GENCB *cb)
|
||||
{
|
||||
return BN_is_prime_fasttest_ex(a, checks, ctx_passed, 0, cb);
|
||||
}
|
||||
|
||||
int BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed,
|
||||
int do_trial_division, BN_GENCB *cb)
|
||||
{
|
||||
int i, j, ret = -1;
|
||||
int k;
|
||||
BN_CTX *ctx = NULL;
|
||||
BIGNUM *A1, *A1_odd, *check; /* taken from ctx */
|
||||
BN_MONT_CTX *mont = NULL;
|
||||
const BIGNUM *A = NULL;
|
||||
|
||||
if (BN_cmp(a, BN_value_one()) <= 0)
|
||||
return 0;
|
||||
|
||||
if (checks == BN_prime_checks)
|
||||
checks = BN_prime_checks_for_size(BN_num_bits(a));
|
||||
|
||||
/* first look for small factors */
|
||||
if (!BN_is_odd(a))
|
||||
/* a is even => a is prime if and only if a == 2 */
|
||||
return BN_is_word(a, 2);
|
||||
if (do_trial_division)
|
||||
{
|
||||
for (i = 1; i < NUMPRIMES; i++)
|
||||
if (BN_mod_word(a, primes[i]) == 0)
|
||||
return 0;
|
||||
if(!BN_GENCB_call(cb, 1, -1))
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (ctx_passed != NULL)
|
||||
ctx = ctx_passed;
|
||||
else
|
||||
if ((ctx=BN_CTX_new()) == NULL)
|
||||
goto err;
|
||||
BN_CTX_start(ctx);
|
||||
|
||||
/* A := abs(a) */
|
||||
if (a->neg)
|
||||
{
|
||||
BIGNUM *t;
|
||||
if ((t = BN_CTX_get(ctx)) == NULL) goto err;
|
||||
BN_copy(t, a);
|
||||
t->neg = 0;
|
||||
A = t;
|
||||
}
|
||||
else
|
||||
A = a;
|
||||
A1 = BN_CTX_get(ctx);
|
||||
A1_odd = BN_CTX_get(ctx);
|
||||
check = BN_CTX_get(ctx);
|
||||
if (check == NULL) goto err;
|
||||
|
||||
/* compute A1 := A - 1 */
|
||||
if (!BN_copy(A1, A))
|
||||
goto err;
|
||||
if (!BN_sub_word(A1, 1))
|
||||
goto err;
|
||||
if (BN_is_zero(A1))
|
||||
{
|
||||
ret = 0;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* write A1 as A1_odd * 2^k */
|
||||
k = 1;
|
||||
while (!BN_is_bit_set(A1, k))
|
||||
k++;
|
||||
if (!BN_rshift(A1_odd, A1, k))
|
||||
goto err;
|
||||
|
||||
/* Montgomery setup for computations mod A */
|
||||
mont = BN_MONT_CTX_new();
|
||||
if (mont == NULL)
|
||||
goto err;
|
||||
if (!BN_MONT_CTX_set(mont, A, ctx))
|
||||
goto err;
|
||||
|
||||
for (i = 0; i < checks; i++)
|
||||
{
|
||||
if (!BN_pseudo_rand_range(check, A1))
|
||||
goto err;
|
||||
if (!BN_add_word(check, 1))
|
||||
goto err;
|
||||
/* now 1 <= check < A */
|
||||
|
||||
j = witness(check, A, A1, A1_odd, k, ctx, mont);
|
||||
if (j == -1) goto err;
|
||||
if (j)
|
||||
{
|
||||
ret=0;
|
||||
goto err;
|
||||
}
|
||||
if(!BN_GENCB_call(cb, 1, i))
|
||||
goto err;
|
||||
}
|
||||
ret=1;
|
||||
err:
|
||||
if (ctx != NULL)
|
||||
{
|
||||
BN_CTX_end(ctx);
|
||||
if (ctx_passed == NULL)
|
||||
BN_CTX_free(ctx);
|
||||
}
|
||||
if (mont != NULL)
|
||||
BN_MONT_CTX_free(mont);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1,
|
||||
const BIGNUM *a1_odd, int k, BN_CTX *ctx, BN_MONT_CTX *mont)
|
||||
{
|
||||
if (!BN_mod_exp_mont(w, w, a1_odd, a, ctx, mont)) /* w := w^a1_odd mod a */
|
||||
return -1;
|
||||
if (BN_is_one(w))
|
||||
return 0; /* probably prime */
|
||||
if (BN_cmp(w, a1) == 0)
|
||||
return 0; /* w == -1 (mod a), 'a' is probably prime */
|
||||
while (--k)
|
||||
{
|
||||
if (!BN_mod_mul(w, w, w, a, ctx)) /* w := w^2 mod a */
|
||||
return -1;
|
||||
if (BN_is_one(w))
|
||||
return 1; /* 'a' is composite, otherwise a previous 'w' would
|
||||
* have been == -1 (mod 'a') */
|
||||
if (BN_cmp(w, a1) == 0)
|
||||
return 0; /* w == -1 (mod a), 'a' is probably prime */
|
||||
}
|
||||
/* If we get here, 'w' is the (a-1)/2-th power of the original 'w',
|
||||
* and it is neither -1 nor +1 -- so 'a' cannot be prime */
|
||||
bn_check_top(w);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int probable_prime(BIGNUM *rnd, int bits)
|
||||
{
|
||||
int i;
|
||||
BN_ULONG mods[NUMPRIMES];
|
||||
BN_ULONG delta,d;
|
||||
|
||||
again:
|
||||
if (!BN_rand(rnd,bits,1,1)) return(0);
|
||||
/* we now have a random number 'rand' to test. */
|
||||
for (i=1; i<NUMPRIMES; i++)
|
||||
mods[i]=BN_mod_word(rnd,(BN_ULONG)primes[i]);
|
||||
delta=0;
|
||||
loop: for (i=1; i<NUMPRIMES; i++)
|
||||
{
|
||||
/* check that rnd is not a prime and also
|
||||
* that gcd(rnd-1,primes) == 1 (except for 2) */
|
||||
if (((mods[i]+delta)%primes[i]) <= 1)
|
||||
{
|
||||
d=delta;
|
||||
delta+=2;
|
||||
/* perhaps need to check for overflow of
|
||||
* delta (but delta can be up to 2^32)
|
||||
* 21-May-98 eay - added overflow check */
|
||||
if (delta < d) goto again;
|
||||
goto loop;
|
||||
}
|
||||
}
|
||||
if (!BN_add_word(rnd,delta)) return(0);
|
||||
bn_check_top(rnd);
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int probable_prime_dh(BIGNUM *rnd, int bits,
|
||||
const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx)
|
||||
{
|
||||
int i,ret=0;
|
||||
BIGNUM *t1;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
if ((t1 = BN_CTX_get(ctx)) == NULL) goto err;
|
||||
|
||||
if (!BN_rand(rnd,bits,0,1)) goto err;
|
||||
|
||||
/* we need ((rnd-rem) % add) == 0 */
|
||||
|
||||
if (!BN_mod(t1,rnd,add,ctx)) goto err;
|
||||
if (!BN_sub(rnd,rnd,t1)) goto err;
|
||||
if (rem == NULL)
|
||||
{ if (!BN_add_word(rnd,1)) goto err; }
|
||||
else
|
||||
{ if (!BN_add(rnd,rnd,rem)) goto err; }
|
||||
|
||||
/* we now have a random number 'rand' to test. */
|
||||
|
||||
loop: for (i=1; i<NUMPRIMES; i++)
|
||||
{
|
||||
/* check that rnd is a prime */
|
||||
if (BN_mod_word(rnd,(BN_ULONG)primes[i]) <= 1)
|
||||
{
|
||||
if (!BN_add(rnd,rnd,add)) goto err;
|
||||
goto loop;
|
||||
}
|
||||
}
|
||||
ret=1;
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
bn_check_top(rnd);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int probable_prime_dh_safe(BIGNUM *p, int bits, const BIGNUM *padd,
|
||||
const BIGNUM *rem, BN_CTX *ctx)
|
||||
{
|
||||
int i,ret=0;
|
||||
BIGNUM *t1,*qadd,*q;
|
||||
|
||||
bits--;
|
||||
BN_CTX_start(ctx);
|
||||
t1 = BN_CTX_get(ctx);
|
||||
q = BN_CTX_get(ctx);
|
||||
qadd = BN_CTX_get(ctx);
|
||||
if (qadd == NULL) goto err;
|
||||
|
||||
if (!BN_rshift1(qadd,padd)) goto err;
|
||||
|
||||
if (!BN_rand(q,bits,0,1)) goto err;
|
||||
|
||||
/* we need ((rnd-rem) % add) == 0 */
|
||||
if (!BN_mod(t1,q,qadd,ctx)) goto err;
|
||||
if (!BN_sub(q,q,t1)) goto err;
|
||||
if (rem == NULL)
|
||||
{ if (!BN_add_word(q,1)) goto err; }
|
||||
else
|
||||
{
|
||||
if (!BN_rshift1(t1,rem)) goto err;
|
||||
if (!BN_add(q,q,t1)) goto err;
|
||||
}
|
||||
|
||||
/* we now have a random number 'rand' to test. */
|
||||
if (!BN_lshift1(p,q)) goto err;
|
||||
if (!BN_add_word(p,1)) goto err;
|
||||
|
||||
loop: for (i=1; i<NUMPRIMES; i++)
|
||||
{
|
||||
/* check that p and q are prime */
|
||||
/* check that for p and q
|
||||
* gcd(p-1,primes) == 1 (except for 2) */
|
||||
if ( (BN_mod_word(p,(BN_ULONG)primes[i]) == 0) ||
|
||||
(BN_mod_word(q,(BN_ULONG)primes[i]) == 0))
|
||||
{
|
||||
if (!BN_add(p,p,padd)) goto err;
|
||||
if (!BN_add(q,q,qadd)) goto err;
|
||||
goto loop;
|
||||
}
|
||||
}
|
||||
ret=1;
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
bn_check_top(p);
|
||||
return(ret);
|
||||
}
|
324
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_rand.c
Executable file
324
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_rand.c
Executable file
@ -0,0 +1,324 @@
|
||||
/* crypto/bn/bn_rand.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2001 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).
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
#include <openssl/rand.h>
|
||||
|
||||
static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
|
||||
{
|
||||
unsigned char *buf=NULL;
|
||||
int ret=0,bit,bytes,mask;
|
||||
time_t tim;
|
||||
|
||||
if (bits == 0)
|
||||
{
|
||||
BN_zero(rnd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
bytes=(bits+7)/8;
|
||||
bit=(bits-1)%8;
|
||||
mask=0xff<<(bit+1);
|
||||
|
||||
buf=(unsigned char *)OPENSSL_malloc(bytes);
|
||||
if (buf == NULL)
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BNerr(BN_F_BNRAND,ERR_R_MALLOC_FAILURE);
|
||||
#endif
|
||||
/*end: comment out , 17Aug2006, Chris */
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* make a random number and set the top and bottom bits */
|
||||
#ifndef RSDK_BUILT
|
||||
time(&tim);
|
||||
#endif
|
||||
RAND_add(&tim,sizeof(tim),0.0);
|
||||
|
||||
|
||||
if (pseudorand)
|
||||
{
|
||||
if (RAND_pseudo_bytes(buf, bytes) == -1)
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RAND_bytes(buf, bytes) <= 0)
|
||||
goto err;
|
||||
}
|
||||
|
||||
#if 1
|
||||
if (pseudorand == 2)
|
||||
{
|
||||
/* generate patterns that are more likely to trigger BN
|
||||
library bugs */
|
||||
int i;
|
||||
unsigned char c;
|
||||
|
||||
for (i = 0; i < bytes; i++)
|
||||
{
|
||||
RAND_pseudo_bytes(&c, 1);
|
||||
if (c >= 128 && i > 0)
|
||||
buf[i] = buf[i-1];
|
||||
else if (c < 42)
|
||||
buf[i] = 0;
|
||||
else if (c < 84)
|
||||
buf[i] = 255;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (top != -1)
|
||||
{
|
||||
if (top)
|
||||
{
|
||||
if (bit == 0)
|
||||
{
|
||||
buf[0]=1;
|
||||
buf[1]|=0x80;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[0]|=(3<<(bit-1));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[0]|=(1<<bit);
|
||||
}
|
||||
}
|
||||
buf[0] &= ~mask;
|
||||
if (bottom) /* set bottom bit if requested */
|
||||
buf[bytes-1]|=1;
|
||||
if (!BN_bin2bn(buf,bytes,rnd)) goto err;
|
||||
ret=1;
|
||||
err:
|
||||
if (buf != NULL)
|
||||
{
|
||||
OPENSSL_cleanse(buf,bytes);
|
||||
OPENSSL_free(buf);
|
||||
}
|
||||
bn_check_top(rnd);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
|
||||
{
|
||||
return bnrand(0, rnd, bits, top, bottom);
|
||||
}
|
||||
|
||||
int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom)
|
||||
{
|
||||
return bnrand(1, rnd, bits, top, bottom);
|
||||
}
|
||||
|
||||
#if 1
|
||||
int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
|
||||
{
|
||||
return bnrand(2, rnd, bits, top, bottom);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* random number r: 0 <= r < range */
|
||||
static int bn_rand_range(int pseudo, BIGNUM *r, BIGNUM *range)
|
||||
{
|
||||
int (*bn_rand)(BIGNUM *, int, int, int) = pseudo ? BN_pseudo_rand : BN_rand;
|
||||
int n;
|
||||
int count = 100;
|
||||
|
||||
if (range->neg || BN_is_zero(range))
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BNerr(BN_F_BN_RAND_RANGE, BN_R_INVALID_RANGE);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
return 0;
|
||||
}
|
||||
|
||||
n = BN_num_bits(range); /* n > 0 */
|
||||
|
||||
/* BN_is_bit_set(range, n - 1) always holds */
|
||||
|
||||
if (n == 1)
|
||||
BN_zero(r);
|
||||
else if (!BN_is_bit_set(range, n - 2) && !BN_is_bit_set(range, n - 3))
|
||||
{
|
||||
/* range = 100..._2,
|
||||
* so 3*range (= 11..._2) is exactly one bit longer than range */
|
||||
do
|
||||
{
|
||||
if (!bn_rand(r, n + 1, -1, 0)) return 0;
|
||||
/* If r < 3*range, use r := r MOD range
|
||||
* (which is either r, r - range, or r - 2*range).
|
||||
* Otherwise, iterate once more.
|
||||
* Since 3*range = 11..._2, each iteration succeeds with
|
||||
* probability >= .75. */
|
||||
if (BN_cmp(r ,range) >= 0)
|
||||
{
|
||||
if (!BN_sub(r, r, range)) return 0;
|
||||
if (BN_cmp(r, range) >= 0)
|
||||
if (!BN_sub(r, r, range)) return 0;
|
||||
}
|
||||
|
||||
if (!--count)
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BNerr(BN_F_BN_RAND_RANGE, BN_R_TOO_MANY_ITERATIONS);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
while (BN_cmp(r, range) >= 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
/* range = 11..._2 or range = 101..._2 */
|
||||
if (!bn_rand(r, n, -1, 0)) return 0;
|
||||
|
||||
if (!--count)
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BNerr(BN_F_BN_RAND_RANGE, BN_R_TOO_MANY_ITERATIONS);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
while (BN_cmp(r, range) >= 0);
|
||||
}
|
||||
|
||||
bn_check_top(r);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int BN_rand_range(BIGNUM *r, BIGNUM *range)
|
||||
{
|
||||
return bn_rand_range(0, r, range);
|
||||
}
|
||||
|
||||
int BN_pseudo_rand_range(BIGNUM *r, BIGNUM *range)
|
||||
{
|
||||
return bn_rand_range(1, r, range);
|
||||
}
|
238
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_recp.c
Executable file
238
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_recp.c
Executable file
@ -0,0 +1,238 @@
|
||||
/* crypto/bn/bn_recp.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
void BN_RECP_CTX_init(BN_RECP_CTX *recp)
|
||||
{
|
||||
BN_init(&(recp->N));
|
||||
BN_init(&(recp->Nr));
|
||||
recp->num_bits=0;
|
||||
recp->flags=0;
|
||||
}
|
||||
|
||||
BN_RECP_CTX *BN_RECP_CTX_new(void)
|
||||
{
|
||||
BN_RECP_CTX *ret;
|
||||
|
||||
if ((ret=(BN_RECP_CTX *)OPENSSL_malloc(sizeof(BN_RECP_CTX))) == NULL)
|
||||
return(NULL);
|
||||
|
||||
BN_RECP_CTX_init(ret);
|
||||
ret->flags=BN_FLG_MALLOCED;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
void BN_RECP_CTX_free(BN_RECP_CTX *recp)
|
||||
{
|
||||
if(recp == NULL)
|
||||
return;
|
||||
|
||||
BN_free(&(recp->N));
|
||||
BN_free(&(recp->Nr));
|
||||
if (recp->flags & BN_FLG_MALLOCED)
|
||||
OPENSSL_free(recp);
|
||||
}
|
||||
|
||||
int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx)
|
||||
{
|
||||
if (!BN_copy(&(recp->N),d)) return 0;
|
||||
BN_zero(&(recp->Nr));
|
||||
recp->num_bits=BN_num_bits(d);
|
||||
recp->shift=0;
|
||||
return(1);
|
||||
}
|
||||
|
||||
int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
|
||||
BN_RECP_CTX *recp, BN_CTX *ctx)
|
||||
{
|
||||
int ret=0;
|
||||
BIGNUM *a;
|
||||
const BIGNUM *ca;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
if ((a = BN_CTX_get(ctx)) == NULL) goto err;
|
||||
if (y != NULL)
|
||||
{
|
||||
if (x == y)
|
||||
{ if (!BN_sqr(a,x,ctx)) goto err; }
|
||||
else
|
||||
{ if (!BN_mul(a,x,y,ctx)) goto err; }
|
||||
ca = a;
|
||||
}
|
||||
else
|
||||
ca=x; /* Just do the mod */
|
||||
|
||||
ret = BN_div_recp(NULL,r,ca,recp,ctx);
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
bn_check_top(r);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
|
||||
BN_RECP_CTX *recp, BN_CTX *ctx)
|
||||
{
|
||||
int i,j,ret=0;
|
||||
BIGNUM *a,*b,*d,*r;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
a=BN_CTX_get(ctx);
|
||||
b=BN_CTX_get(ctx);
|
||||
if (dv != NULL)
|
||||
d=dv;
|
||||
else
|
||||
d=BN_CTX_get(ctx);
|
||||
if (rem != NULL)
|
||||
r=rem;
|
||||
else
|
||||
r=BN_CTX_get(ctx);
|
||||
if (a == NULL || b == NULL || d == NULL || r == NULL) goto err;
|
||||
|
||||
if (BN_ucmp(m,&(recp->N)) < 0)
|
||||
{
|
||||
BN_zero(d);
|
||||
if (!BN_copy(r,m)) return 0;
|
||||
BN_CTX_end(ctx);
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* We want the remainder
|
||||
* Given input of ABCDEF / ab
|
||||
* we need multiply ABCDEF by 3 digests of the reciprocal of ab
|
||||
*
|
||||
*/
|
||||
|
||||
/* i := max(BN_num_bits(m), 2*BN_num_bits(N)) */
|
||||
i=BN_num_bits(m);
|
||||
j=recp->num_bits<<1;
|
||||
if (j>i) i=j;
|
||||
|
||||
/* Nr := round(2^i / N) */
|
||||
if (i != recp->shift)
|
||||
recp->shift=BN_reciprocal(&(recp->Nr),&(recp->N),
|
||||
i,ctx); /* BN_reciprocal returns i, or -1 for an error */
|
||||
if (recp->shift == -1) goto err;
|
||||
|
||||
/* d := |round(round(m / 2^BN_num_bits(N)) * recp->Nr / 2^(i - BN_num_bits(N)))|
|
||||
* = |round(round(m / 2^BN_num_bits(N)) * round(2^i / N) / 2^(i - BN_num_bits(N)))|
|
||||
* <= |(m / 2^BN_num_bits(N)) * (2^i / N) * (2^BN_num_bits(N) / 2^i)|
|
||||
* = |m/N|
|
||||
*/
|
||||
if (!BN_rshift(a,m,recp->num_bits)) goto err;
|
||||
if (!BN_mul(b,a,&(recp->Nr),ctx)) goto err;
|
||||
if (!BN_rshift(d,b,i-recp->num_bits)) goto err;
|
||||
d->neg=0;
|
||||
|
||||
if (!BN_mul(b,&(recp->N),d,ctx)) goto err;
|
||||
if (!BN_usub(r,m,b)) goto err;
|
||||
r->neg=0;
|
||||
|
||||
#if 1
|
||||
j=0;
|
||||
while (BN_ucmp(r,&(recp->N)) >= 0)
|
||||
{
|
||||
if (j++ > 2)
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BNerr(BN_F_BN_DIV_RECP,BN_R_BAD_RECIPROCAL);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
goto err;
|
||||
}
|
||||
if (!BN_usub(r,r,&(recp->N))) goto err;
|
||||
if (!BN_add_word(d,1)) goto err;
|
||||
}
|
||||
#endif
|
||||
|
||||
r->neg=BN_is_zero(r)?0:m->neg;
|
||||
d->neg=m->neg^recp->N.neg;
|
||||
ret=1;
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
bn_check_top(dv);
|
||||
bn_check_top(rem);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/* len is the expected size of the result
|
||||
* We actually calculate with an extra word of precision, so
|
||||
* we can do faster division if the remainder is not required.
|
||||
*/
|
||||
/* r := 2^len / m */
|
||||
int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx)
|
||||
{
|
||||
int ret= -1;
|
||||
BIGNUM *t;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
if((t = BN_CTX_get(ctx)) == NULL) goto err;
|
||||
|
||||
if (!BN_set_bit(t,len)) goto err;
|
||||
|
||||
if (!BN_div(r,NULL,t,m,ctx)) goto err;
|
||||
|
||||
ret=len;
|
||||
err:
|
||||
bn_check_top(r);
|
||||
BN_CTX_end(ctx);
|
||||
return(ret);
|
||||
}
|
220
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_shift.c
Executable file
220
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_shift.c
Executable file
@ -0,0 +1,220 @@
|
||||
/* crypto/bn/bn_shift.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
int BN_lshift1(BIGNUM *r, const BIGNUM *a)
|
||||
{
|
||||
register BN_ULONG *ap,*rp,t,c;
|
||||
int i;
|
||||
|
||||
bn_check_top(r);
|
||||
bn_check_top(a);
|
||||
|
||||
if (r != a)
|
||||
{
|
||||
r->neg=a->neg;
|
||||
if (bn_wexpand(r,a->top+1) == NULL) return(0);
|
||||
r->top=a->top;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bn_wexpand(r,a->top+1) == NULL) return(0);
|
||||
}
|
||||
ap=a->d;
|
||||
rp=r->d;
|
||||
c=0;
|
||||
for (i=0; i<a->top; i++)
|
||||
{
|
||||
t= *(ap++);
|
||||
*(rp++)=((t<<1)|c)&BN_MASK2;
|
||||
c=(t & BN_TBIT)?1:0;
|
||||
}
|
||||
if (c)
|
||||
{
|
||||
*rp=1;
|
||||
r->top++;
|
||||
}
|
||||
bn_check_top(r);
|
||||
return(1);
|
||||
}
|
||||
|
||||
int BN_rshift1(BIGNUM *r, const BIGNUM *a)
|
||||
{
|
||||
BN_ULONG *ap,*rp,t,c;
|
||||
int i;
|
||||
|
||||
bn_check_top(r);
|
||||
bn_check_top(a);
|
||||
|
||||
if (BN_is_zero(a))
|
||||
{
|
||||
BN_zero(r);
|
||||
return(1);
|
||||
}
|
||||
if (a != r)
|
||||
{
|
||||
if (bn_wexpand(r,a->top) == NULL) return(0);
|
||||
r->top=a->top;
|
||||
r->neg=a->neg;
|
||||
}
|
||||
ap=a->d;
|
||||
rp=r->d;
|
||||
c=0;
|
||||
for (i=a->top-1; i>=0; i--)
|
||||
{
|
||||
t=ap[i];
|
||||
rp[i]=((t>>1)&BN_MASK2)|c;
|
||||
c=(t&1)?BN_TBIT:0;
|
||||
}
|
||||
bn_correct_top(r);
|
||||
bn_check_top(r);
|
||||
return(1);
|
||||
}
|
||||
|
||||
int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
|
||||
{
|
||||
int i,nw,lb,rb;
|
||||
BN_ULONG *t,*f;
|
||||
BN_ULONG l;
|
||||
|
||||
bn_check_top(r);
|
||||
bn_check_top(a);
|
||||
|
||||
r->neg=a->neg;
|
||||
nw=n/BN_BITS2;
|
||||
if (bn_wexpand(r,a->top+nw+1) == NULL) return(0);
|
||||
lb=n%BN_BITS2;
|
||||
rb=BN_BITS2-lb;
|
||||
f=a->d;
|
||||
t=r->d;
|
||||
t[a->top+nw]=0;
|
||||
if (lb == 0)
|
||||
for (i=a->top-1; i>=0; i--)
|
||||
t[nw+i]=f[i];
|
||||
else
|
||||
for (i=a->top-1; i>=0; i--)
|
||||
{
|
||||
l=f[i];
|
||||
t[nw+i+1]|=(l>>rb)&BN_MASK2;
|
||||
t[nw+i]=(l<<lb)&BN_MASK2;
|
||||
}
|
||||
memset(t,0,nw*sizeof(t[0]));
|
||||
/* for (i=0; i<nw; i++)
|
||||
t[i]=0;*/
|
||||
r->top=a->top+nw+1;
|
||||
bn_correct_top(r);
|
||||
bn_check_top(r);
|
||||
return(1);
|
||||
}
|
||||
|
||||
int BN_rshift(BIGNUM *r, const BIGNUM *a, int n)
|
||||
{
|
||||
int i,j,nw,lb,rb;
|
||||
BN_ULONG *t,*f;
|
||||
BN_ULONG l,tmp;
|
||||
|
||||
bn_check_top(r);
|
||||
bn_check_top(a);
|
||||
|
||||
nw=n/BN_BITS2;
|
||||
rb=n%BN_BITS2;
|
||||
lb=BN_BITS2-rb;
|
||||
if (nw > a->top || a->top == 0)
|
||||
{
|
||||
BN_zero(r);
|
||||
return(1);
|
||||
}
|
||||
if (r != a)
|
||||
{
|
||||
r->neg=a->neg;
|
||||
if (bn_wexpand(r,a->top-nw+1) == NULL) return(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (n == 0)
|
||||
return 1; /* or the copying loop will go berserk */
|
||||
}
|
||||
|
||||
f= &(a->d[nw]);
|
||||
t=r->d;
|
||||
j=a->top-nw;
|
||||
r->top=j;
|
||||
|
||||
if (rb == 0)
|
||||
{
|
||||
for (i=j; i != 0; i--)
|
||||
*(t++)= *(f++);
|
||||
}
|
||||
else
|
||||
{
|
||||
l= *(f++);
|
||||
for (i=j-1; i != 0; i--)
|
||||
{
|
||||
tmp =(l>>rb)&BN_MASK2;
|
||||
l= *(f++);
|
||||
*(t++) =(tmp|(l<<lb))&BN_MASK2;
|
||||
}
|
||||
*(t++) =(l>>rb)&BN_MASK2;
|
||||
}
|
||||
bn_correct_top(r);
|
||||
bn_check_top(r);
|
||||
return(1);
|
||||
}
|
294
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_sqr.c
Executable file
294
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_sqr.c
Executable file
@ -0,0 +1,294 @@
|
||||
/* crypto/bn/bn_sqr.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
/* r must not be a */
|
||||
/* I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96 */
|
||||
int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
|
||||
{
|
||||
int max,al;
|
||||
int ret = 0;
|
||||
BIGNUM *tmp,*rr;
|
||||
|
||||
#ifdef BN_COUNT
|
||||
fprintf(stderr,"BN_sqr %d * %d\n",a->top,a->top);
|
||||
#endif
|
||||
bn_check_top(a);
|
||||
|
||||
al=a->top;
|
||||
if (al <= 0)
|
||||
{
|
||||
r->top=0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
rr=(a != r) ? r : BN_CTX_get(ctx);
|
||||
tmp=BN_CTX_get(ctx);
|
||||
if (!rr || !tmp) goto err;
|
||||
|
||||
max = 2 * al; /* Non-zero (from above) */
|
||||
if (bn_wexpand(rr,max) == NULL) goto err;
|
||||
|
||||
if (al == 4)
|
||||
{
|
||||
#ifndef BN_SQR_COMBA
|
||||
BN_ULONG t[8];
|
||||
bn_sqr_normal(rr->d,a->d,4,t);
|
||||
#else
|
||||
bn_sqr_comba4(rr->d,a->d);
|
||||
#endif
|
||||
}
|
||||
else if (al == 8)
|
||||
{
|
||||
#ifndef BN_SQR_COMBA
|
||||
BN_ULONG t[16];
|
||||
bn_sqr_normal(rr->d,a->d,8,t);
|
||||
#else
|
||||
bn_sqr_comba8(rr->d,a->d);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(BN_RECURSION)
|
||||
if (al < BN_SQR_RECURSIVE_SIZE_NORMAL)
|
||||
{
|
||||
BN_ULONG t[BN_SQR_RECURSIVE_SIZE_NORMAL*2];
|
||||
bn_sqr_normal(rr->d,a->d,al,t);
|
||||
}
|
||||
else
|
||||
{
|
||||
int j,k;
|
||||
|
||||
j=BN_num_bits_word((BN_ULONG)al);
|
||||
j=1<<(j-1);
|
||||
k=j+j;
|
||||
if (al == j)
|
||||
{
|
||||
if (bn_wexpand(tmp,k*2) == NULL) goto err;
|
||||
bn_sqr_recursive(rr->d,a->d,al,tmp->d);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bn_wexpand(tmp,max) == NULL) goto err;
|
||||
bn_sqr_normal(rr->d,a->d,al,tmp->d);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (bn_wexpand(tmp,max) == NULL) goto err;
|
||||
bn_sqr_normal(rr->d,a->d,al,tmp->d);
|
||||
#endif
|
||||
}
|
||||
|
||||
rr->neg=0;
|
||||
/* If the most-significant half of the top word of 'a' is zero, then
|
||||
* the square of 'a' will max-1 words. */
|
||||
if(a->d[al - 1] == (a->d[al - 1] & BN_MASK2l))
|
||||
rr->top = max - 1;
|
||||
else
|
||||
rr->top = max;
|
||||
if (rr != r) BN_copy(r,rr);
|
||||
ret = 1;
|
||||
err:
|
||||
bn_check_top(rr);
|
||||
bn_check_top(tmp);
|
||||
BN_CTX_end(ctx);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/* tmp must have 2*n words */
|
||||
void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp)
|
||||
{
|
||||
int i,j,max;
|
||||
const BN_ULONG *ap;
|
||||
BN_ULONG *rp;
|
||||
|
||||
max=n*2;
|
||||
ap=a;
|
||||
rp=r;
|
||||
rp[0]=rp[max-1]=0;
|
||||
rp++;
|
||||
j=n;
|
||||
|
||||
if (--j > 0)
|
||||
{
|
||||
ap++;
|
||||
rp[j]=bn_mul_words(rp,ap,j,ap[-1]);
|
||||
rp+=2;
|
||||
}
|
||||
|
||||
for (i=n-2; i>0; i--)
|
||||
{
|
||||
j--;
|
||||
ap++;
|
||||
rp[j]=bn_mul_add_words(rp,ap,j,ap[-1]);
|
||||
rp+=2;
|
||||
}
|
||||
|
||||
bn_add_words(r,r,r,max);
|
||||
|
||||
/* There will not be a carry */
|
||||
|
||||
bn_sqr_words(tmp,a,n);
|
||||
|
||||
bn_add_words(r,r,tmp,max);
|
||||
}
|
||||
|
||||
#ifdef BN_RECURSION
|
||||
/* r is 2*n words in size,
|
||||
* a and b are both n words in size. (There's not actually a 'b' here ...)
|
||||
* n must be a power of 2.
|
||||
* We multiply and return the result.
|
||||
* t must be 2*n words in size
|
||||
* We calculate
|
||||
* a[0]*b[0]
|
||||
* a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0])
|
||||
* a[1]*b[1]
|
||||
*/
|
||||
void bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t)
|
||||
{
|
||||
int n=n2/2;
|
||||
int zero,c1;
|
||||
BN_ULONG ln,lo,*p;
|
||||
|
||||
#ifdef BN_COUNT
|
||||
fprintf(stderr," bn_sqr_recursive %d * %d\n",n2,n2);
|
||||
#endif
|
||||
if (n2 == 4)
|
||||
{
|
||||
#ifndef BN_SQR_COMBA
|
||||
bn_sqr_normal(r,a,4,t);
|
||||
#else
|
||||
bn_sqr_comba4(r,a);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
else if (n2 == 8)
|
||||
{
|
||||
#ifndef BN_SQR_COMBA
|
||||
bn_sqr_normal(r,a,8,t);
|
||||
#else
|
||||
bn_sqr_comba8(r,a);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (n2 < BN_SQR_RECURSIVE_SIZE_NORMAL)
|
||||
{
|
||||
bn_sqr_normal(r,a,n2,t);
|
||||
return;
|
||||
}
|
||||
/* r=(a[0]-a[1])*(a[1]-a[0]) */
|
||||
c1=bn_cmp_words(a,&(a[n]),n);
|
||||
zero=0;
|
||||
if (c1 > 0)
|
||||
bn_sub_words(t,a,&(a[n]),n);
|
||||
else if (c1 < 0)
|
||||
bn_sub_words(t,&(a[n]),a,n);
|
||||
else
|
||||
zero=1;
|
||||
|
||||
/* The result will always be negative unless it is zero */
|
||||
p= &(t[n2*2]);
|
||||
|
||||
if (!zero)
|
||||
bn_sqr_recursive(&(t[n2]),t,n,p);
|
||||
else
|
||||
memset(&(t[n2]),0,n2*sizeof(BN_ULONG));
|
||||
bn_sqr_recursive(r,a,n,p);
|
||||
bn_sqr_recursive(&(r[n2]),&(a[n]),n,p);
|
||||
|
||||
/* t[32] holds (a[0]-a[1])*(a[1]-a[0]), it is negative or zero
|
||||
* r[10] holds (a[0]*b[0])
|
||||
* r[32] holds (b[1]*b[1])
|
||||
*/
|
||||
|
||||
c1=(int)(bn_add_words(t,r,&(r[n2]),n2));
|
||||
|
||||
/* t[32] is negative */
|
||||
c1-=(int)(bn_sub_words(&(t[n2]),t,&(t[n2]),n2));
|
||||
|
||||
/* t[32] holds (a[0]-a[1])*(a[1]-a[0])+(a[0]*a[0])+(a[1]*a[1])
|
||||
* r[10] holds (a[0]*a[0])
|
||||
* r[32] holds (a[1]*a[1])
|
||||
* c1 holds the carry bits
|
||||
*/
|
||||
c1+=(int)(bn_add_words(&(r[n]),&(r[n]),&(t[n2]),n2));
|
||||
if (c1)
|
||||
{
|
||||
p= &(r[n+n2]);
|
||||
lo= *p;
|
||||
ln=(lo+c1)&BN_MASK2;
|
||||
*p=ln;
|
||||
|
||||
/* The overflow will stop before we over write
|
||||
* words we should not overwrite */
|
||||
if (ln < (BN_ULONG)c1)
|
||||
{
|
||||
do {
|
||||
p++;
|
||||
lo= *p;
|
||||
ln=(lo+1)&BN_MASK2;
|
||||
*p=ln;
|
||||
} while (ln == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
253
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_word.c
Executable file
253
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/bn/bn_word.c
Executable file
@ -0,0 +1,253 @@
|
||||
/* crypto/bn/bn_word.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w)
|
||||
{
|
||||
/*Begin: for RSDK, the module operation of the long long type is unavailable, 17Aug2006, Chris */
|
||||
//#if BN_LLONG
|
||||
#if !defined(BN_LLONG) || defined(RSDK_BUILT)
|
||||
/*End:: for RSDK, the module operation of the long long type is unavailable, 17Aug2006, Chris */
|
||||
BN_ULONG ret=0;
|
||||
#else
|
||||
BN_ULLONG ret=0;
|
||||
#endif
|
||||
int i;
|
||||
|
||||
if (w == 0)
|
||||
return (BN_ULONG)-1;
|
||||
|
||||
bn_check_top(a);
|
||||
w&=BN_MASK2;
|
||||
for (i=a->top-1; i>=0; i--)
|
||||
{
|
||||
/*Begin: for RSDK, the module operation of the long long type is unavailable, 17Aug2006, Chris */
|
||||
//#if BN_LLONG
|
||||
#if !defined(BN_LLONG) || defined(RSDK_BUILT)
|
||||
/*End:: for RSDK, the module operation of the long long type is unavailable, 17Aug2006, Chris */
|
||||
ret=((ret<<BN_BITS4)|((a->d[i]>>BN_BITS4)&BN_MASK2l))%w;
|
||||
ret=((ret<<BN_BITS4)|(a->d[i]&BN_MASK2l))%w;
|
||||
#else
|
||||
ret=(BN_ULLONG)(((ret<<(BN_ULLONG)BN_BITS2)|a->d[i])%
|
||||
(BN_ULLONG)w);
|
||||
#endif
|
||||
}
|
||||
return((BN_ULONG)ret);
|
||||
}
|
||||
|
||||
BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w)
|
||||
{
|
||||
BN_ULONG ret = 0;
|
||||
int i, j;
|
||||
|
||||
bn_check_top(a);
|
||||
w &= BN_MASK2;
|
||||
|
||||
if (!w)
|
||||
/* actually this an error (division by zero) */
|
||||
return (BN_ULONG)-1;
|
||||
if (a->top == 0)
|
||||
return 0;
|
||||
|
||||
/* normalize input (so bn_div_words doesn't complain) */
|
||||
j = BN_BITS2 - BN_num_bits_word(w);
|
||||
w <<= j;
|
||||
if (!BN_lshift(a, a, j))
|
||||
return (BN_ULONG)-1;
|
||||
|
||||
for (i=a->top-1; i>=0; i--)
|
||||
{
|
||||
BN_ULONG l,d;
|
||||
|
||||
l=a->d[i];
|
||||
d=bn_div_words(ret,l,w);
|
||||
ret=(l-((d*w)&BN_MASK2))&BN_MASK2;
|
||||
a->d[i]=d;
|
||||
}
|
||||
if ((a->top > 0) && (a->d[a->top-1] == 0))
|
||||
a->top--;
|
||||
ret >>= j;
|
||||
bn_check_top(a);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
int BN_add_word(BIGNUM *a, BN_ULONG w)
|
||||
{
|
||||
BN_ULONG l;
|
||||
int i;
|
||||
|
||||
bn_check_top(a);
|
||||
w &= BN_MASK2;
|
||||
|
||||
/* degenerate case: w is zero */
|
||||
if (!w) return 1;
|
||||
/* degenerate case: a is zero */
|
||||
if(BN_is_zero(a)) return BN_set_word(a, w);
|
||||
/* handle 'a' when negative */
|
||||
if (a->neg)
|
||||
{
|
||||
a->neg=0;
|
||||
i=BN_sub_word(a,w);
|
||||
if (!BN_is_zero(a))
|
||||
a->neg=!(a->neg);
|
||||
return(i);
|
||||
}
|
||||
/* Only expand (and risk failing) if it's possibly necessary */
|
||||
if (((BN_ULONG)(a->d[a->top - 1] + 1) == 0) &&
|
||||
(bn_wexpand(a,a->top+1) == NULL))
|
||||
return(0);
|
||||
i=0;
|
||||
for (;;)
|
||||
{
|
||||
if (i >= a->top)
|
||||
l=w;
|
||||
else
|
||||
l=(a->d[i]+w)&BN_MASK2;
|
||||
a->d[i]=l;
|
||||
if (w > l)
|
||||
w=1;
|
||||
else
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
if (i >= a->top)
|
||||
a->top++;
|
||||
bn_check_top(a);
|
||||
return(1);
|
||||
}
|
||||
|
||||
int BN_sub_word(BIGNUM *a, BN_ULONG w)
|
||||
{
|
||||
int i;
|
||||
|
||||
bn_check_top(a);
|
||||
w &= BN_MASK2;
|
||||
|
||||
/* degenerate case: w is zero */
|
||||
if (!w) return 1;
|
||||
/* degenerate case: a is zero */
|
||||
if(BN_is_zero(a))
|
||||
{
|
||||
i = BN_set_word(a,w);
|
||||
if (i != 0)
|
||||
BN_set_negative(a, 1);
|
||||
return i;
|
||||
}
|
||||
/* handle 'a' when negative */
|
||||
if (a->neg)
|
||||
{
|
||||
a->neg=0;
|
||||
i=BN_add_word(a,w);
|
||||
a->neg=1;
|
||||
return(i);
|
||||
}
|
||||
|
||||
if ((a->top == 1) && (a->d[0] < w))
|
||||
{
|
||||
a->d[0]=w-a->d[0];
|
||||
a->neg=1;
|
||||
return(1);
|
||||
}
|
||||
i=0;
|
||||
for (;;)
|
||||
{
|
||||
if (a->d[i] >= w)
|
||||
{
|
||||
a->d[i]-=w;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
a->d[i]=(a->d[i]-w)&BN_MASK2;
|
||||
i++;
|
||||
w=1;
|
||||
}
|
||||
}
|
||||
if ((a->d[i] == 0) && (i == (a->top-1)))
|
||||
a->top--;
|
||||
bn_check_top(a);
|
||||
return(1);
|
||||
}
|
||||
|
||||
int BN_mul_word(BIGNUM *a, BN_ULONG w)
|
||||
{
|
||||
BN_ULONG ll;
|
||||
|
||||
bn_check_top(a);
|
||||
w&=BN_MASK2;
|
||||
if (a->top)
|
||||
{
|
||||
if (w == 0)
|
||||
BN_zero(a);
|
||||
else
|
||||
{
|
||||
ll=bn_mul_words(a->d,a->d,a->top,w);
|
||||
if (ll)
|
||||
{
|
||||
if (bn_wexpand(a,a->top+1) == NULL) return(0);
|
||||
a->d[a->top++]=ll;
|
||||
}
|
||||
}
|
||||
}
|
||||
bn_check_top(a);
|
||||
return(1);
|
||||
}
|
||||
|
142
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/dh/dh_check.c
Executable file
142
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/dh/dh_check.c
Executable file
@ -0,0 +1,142 @@
|
||||
/* crypto/dh/dh_check.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/dh.h>
|
||||
|
||||
/* Check that p is a safe prime and
|
||||
* if g is 2, 3 or 5, check that is is a suitable generator
|
||||
* where
|
||||
* for 2, p mod 24 == 11
|
||||
* for 3, p mod 12 == 5
|
||||
* for 5, p mod 10 == 3 or 7
|
||||
* should hold.
|
||||
*/
|
||||
|
||||
int DH_check(const DH *dh, int *ret)
|
||||
{
|
||||
int ok=0;
|
||||
BN_CTX *ctx=NULL;
|
||||
BN_ULONG l;
|
||||
BIGNUM *q=NULL;
|
||||
|
||||
*ret=0;
|
||||
ctx=BN_CTX_new();
|
||||
if (ctx == NULL) goto err;
|
||||
q=BN_new();
|
||||
if (q == NULL) goto err;
|
||||
|
||||
if (BN_is_word(dh->g,DH_GENERATOR_2))
|
||||
{
|
||||
l=BN_mod_word(dh->p,24);
|
||||
if (l != 11) *ret|=DH_NOT_SUITABLE_GENERATOR;
|
||||
}
|
||||
#if 0
|
||||
else if (BN_is_word(dh->g,DH_GENERATOR_3))
|
||||
{
|
||||
l=BN_mod_word(dh->p,12);
|
||||
if (l != 5) *ret|=DH_NOT_SUITABLE_GENERATOR;
|
||||
}
|
||||
#endif
|
||||
else if (BN_is_word(dh->g,DH_GENERATOR_5))
|
||||
{
|
||||
l=BN_mod_word(dh->p,10);
|
||||
if ((l != 3) && (l != 7))
|
||||
*ret|=DH_NOT_SUITABLE_GENERATOR;
|
||||
}
|
||||
else
|
||||
*ret|=DH_UNABLE_TO_CHECK_GENERATOR;
|
||||
|
||||
if (!BN_is_prime_ex(dh->p,BN_prime_checks,ctx,NULL))
|
||||
*ret|=DH_CHECK_P_NOT_PRIME;
|
||||
else
|
||||
{
|
||||
if (!BN_rshift1(q,dh->p)) goto err;
|
||||
if (!BN_is_prime_ex(q,BN_prime_checks,ctx,NULL))
|
||||
*ret|=DH_CHECK_P_NOT_SAFE_PRIME;
|
||||
}
|
||||
ok=1;
|
||||
err:
|
||||
if (ctx != NULL) BN_CTX_free(ctx);
|
||||
if (q != NULL) BN_free(q);
|
||||
return(ok);
|
||||
}
|
||||
|
||||
int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret)
|
||||
{
|
||||
int ok=0;
|
||||
BIGNUM *q=NULL;
|
||||
|
||||
*ret=0;
|
||||
q=BN_new();
|
||||
if (q == NULL) goto err;
|
||||
BN_set_word(q,1);
|
||||
if (BN_cmp(pub_key,q) <= 0)
|
||||
*ret|=DH_CHECK_PUBKEY_TOO_SMALL;
|
||||
BN_copy(q,dh->p);
|
||||
BN_sub_word(q,1);
|
||||
if (BN_cmp(pub_key,q) >= 0)
|
||||
*ret|=DH_CHECK_PUBKEY_TOO_LARGE;
|
||||
|
||||
ok = 1;
|
||||
err:
|
||||
if (q != NULL) BN_free(q);
|
||||
return(ok);
|
||||
}
|
186
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/dh/dh_gen.c
Executable file
186
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/dh/dh_gen.c
Executable file
@ -0,0 +1,186 @@
|
||||
/* crypto/dh/dh_gen.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* NB: These functions have been upgraded - the previous prototypes are in
|
||||
* dh_depr.c as wrappers to these ones.
|
||||
* - Geoff
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/dh.h>
|
||||
|
||||
static int dh_builtin_genparams(DH *ret, int prime_len, int generator, BN_GENCB *cb);
|
||||
|
||||
int DH_generate_parameters_ex(DH *ret, int prime_len, int generator, BN_GENCB *cb)
|
||||
{
|
||||
if(ret->meth->generate_params)
|
||||
return ret->meth->generate_params(ret, prime_len, generator, cb);
|
||||
return dh_builtin_genparams(ret, prime_len, generator, cb);
|
||||
}
|
||||
|
||||
/* We generate DH parameters as follows
|
||||
* find a prime q which is prime_len/2 bits long.
|
||||
* p=(2*q)+1 or (p-1)/2 = q
|
||||
* For this case, g is a generator if
|
||||
* g^((p-1)/q) mod p != 1 for values of q which are the factors of p-1.
|
||||
* Since the factors of p-1 are q and 2, we just need to check
|
||||
* g^2 mod p != 1 and g^q mod p != 1.
|
||||
*
|
||||
* Having said all that,
|
||||
* there is another special case method for the generators 2, 3 and 5.
|
||||
* for 2, p mod 24 == 11
|
||||
* for 3, p mod 12 == 5 <<<<< does not work for safe primes.
|
||||
* for 5, p mod 10 == 3 or 7
|
||||
*
|
||||
* Thanks to Phil Karn <karn@qualcomm.com> for the pointers about the
|
||||
* special generators and for answering some of my questions.
|
||||
*
|
||||
* I've implemented the second simple method :-).
|
||||
* Since DH should be using a safe prime (both p and q are prime),
|
||||
* this generator function can take a very very long time to run.
|
||||
*/
|
||||
/* Actually there is no reason to insist that 'generator' be a generator.
|
||||
* It's just as OK (and in some sense better) to use a generator of the
|
||||
* order-q subgroup.
|
||||
*/
|
||||
static int dh_builtin_genparams(DH *ret, int prime_len, int generator, BN_GENCB *cb)
|
||||
{
|
||||
BIGNUM *t1,*t2;
|
||||
int g,ok= -1;
|
||||
BN_CTX *ctx=NULL;
|
||||
|
||||
ctx=BN_CTX_new();
|
||||
if (ctx == NULL) goto err;
|
||||
BN_CTX_start(ctx);
|
||||
t1 = BN_CTX_get(ctx);
|
||||
t2 = BN_CTX_get(ctx);
|
||||
if (t1 == NULL || t2 == NULL) goto err;
|
||||
|
||||
/* Make sure 'ret' has the necessary elements */
|
||||
if(!ret->p && ((ret->p = BN_new()) == NULL)) goto err;
|
||||
if(!ret->g && ((ret->g = BN_new()) == NULL)) goto err;
|
||||
|
||||
if (generator <= 1)
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
DHerr(DH_F_DH_BUILTIN_GENPARAMS, DH_R_BAD_GENERATOR);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
goto err;
|
||||
}
|
||||
if (generator == DH_GENERATOR_2)
|
||||
{
|
||||
if (!BN_set_word(t1,24)) goto err;
|
||||
if (!BN_set_word(t2,11)) goto err;
|
||||
g=2;
|
||||
}
|
||||
#if 0 /* does not work for safe primes */
|
||||
else if (generator == DH_GENERATOR_3)
|
||||
{
|
||||
if (!BN_set_word(t1,12)) goto err;
|
||||
if (!BN_set_word(t2,5)) goto err;
|
||||
g=3;
|
||||
}
|
||||
#endif
|
||||
else if (generator == DH_GENERATOR_5)
|
||||
{
|
||||
if (!BN_set_word(t1,10)) goto err;
|
||||
if (!BN_set_word(t2,3)) goto err;
|
||||
/* BN_set_word(t3,7); just have to miss
|
||||
* out on these ones :-( */
|
||||
g=5;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* in the general case, don't worry if 'generator' is a
|
||||
* generator or not: since we are using safe primes,
|
||||
* it will generate either an order-q or an order-2q group,
|
||||
* which both is OK */
|
||||
if (!BN_set_word(t1,2)) goto err;
|
||||
if (!BN_set_word(t2,1)) goto err;
|
||||
g=generator;
|
||||
}
|
||||
|
||||
if(prime_len==3072)
|
||||
get_rfc3526_prime_3072(ret->p);
|
||||
else
|
||||
if(!BN_generate_prime_ex(ret->p,prime_len,1,t1,t2,cb)) goto err;
|
||||
if(!BN_GENCB_call(cb, 3, 0)) goto err;
|
||||
if (!BN_set_word(ret->g,g)) goto err;
|
||||
ok=1;
|
||||
err:
|
||||
if (ok == -1)
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
DHerr(DH_F_DH_BUILTIN_GENPARAMS,ERR_R_BN_LIB);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
ok=0;
|
||||
}
|
||||
|
||||
if (ctx != NULL)
|
||||
{
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx);
|
||||
}
|
||||
return ok;
|
||||
}
|
272
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/dh/dh_key.c
Executable file
272
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/dh/dh_key.c
Executable file
@ -0,0 +1,272 @@
|
||||
/* crypto/dh/dh_key.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/dh.h>
|
||||
|
||||
static int generate_key(DH *dh);
|
||||
static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh);
|
||||
static int dh_bn_mod_exp(const DH *dh, BIGNUM *r,
|
||||
const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx,
|
||||
BN_MONT_CTX *m_ctx);
|
||||
static int dh_init(DH *dh);
|
||||
static int dh_finish(DH *dh);
|
||||
|
||||
int DH_generate_key(DH *dh)
|
||||
{
|
||||
return dh->meth->generate_key(dh);
|
||||
}
|
||||
|
||||
int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
|
||||
{
|
||||
return dh->meth->compute_key(key, pub_key, dh);
|
||||
}
|
||||
|
||||
static DH_METHOD dh_ossl = {
|
||||
"OpenSSL DH Method",
|
||||
generate_key,
|
||||
compute_key,
|
||||
dh_bn_mod_exp,
|
||||
dh_init,
|
||||
dh_finish,
|
||||
0,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
const DH_METHOD *DH_OpenSSL(void)
|
||||
{
|
||||
return &dh_ossl;
|
||||
}
|
||||
|
||||
static int generate_key(DH *dh)
|
||||
{
|
||||
int ok=0;
|
||||
int generate_new_key=0;
|
||||
unsigned l;
|
||||
BN_CTX *ctx;
|
||||
BN_MONT_CTX *mont=NULL;
|
||||
BIGNUM *pub_key=NULL,*priv_key=NULL;
|
||||
|
||||
ctx = BN_CTX_new();
|
||||
if (ctx == NULL) goto err;
|
||||
|
||||
if (dh->priv_key == NULL)
|
||||
{
|
||||
priv_key=BN_new();
|
||||
if (priv_key == NULL) goto err;
|
||||
generate_new_key=1;
|
||||
}
|
||||
else
|
||||
priv_key=dh->priv_key;
|
||||
|
||||
if (dh->pub_key == NULL)
|
||||
{
|
||||
pub_key=BN_new();
|
||||
if (pub_key == NULL) goto err;
|
||||
}
|
||||
else
|
||||
pub_key=dh->pub_key;
|
||||
|
||||
|
||||
if (dh->flags & DH_FLAG_CACHE_MONT_P)
|
||||
{
|
||||
mont = BN_MONT_CTX_set_locked(&dh->method_mont_p,
|
||||
CRYPTO_LOCK_DH, dh->p, ctx);
|
||||
if (!mont)
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (generate_new_key)
|
||||
{
|
||||
l = dh->length ? dh->length : BN_num_bits(dh->p)-1; /* secret exponent length */
|
||||
if (!BN_rand(priv_key, l, 0, 0)) goto err;
|
||||
}
|
||||
|
||||
{
|
||||
BIGNUM local_prk;
|
||||
BIGNUM *prk;
|
||||
|
||||
if ((dh->flags & DH_FLAG_NO_EXP_CONSTTIME) == 0)
|
||||
{
|
||||
BN_init(&local_prk);
|
||||
prk = &local_prk;
|
||||
BN_with_flags(prk, priv_key, BN_FLG_EXP_CONSTTIME);
|
||||
}
|
||||
else
|
||||
prk = priv_key;
|
||||
|
||||
if (!dh->meth->bn_mod_exp(dh, pub_key, dh->g, prk, dh->p, ctx, mont)) goto err;
|
||||
}
|
||||
|
||||
dh->pub_key=pub_key;
|
||||
dh->priv_key=priv_key;
|
||||
ok=1;
|
||||
err:
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
if (ok != 1)
|
||||
DHerr(DH_F_GENERATE_KEY,ERR_R_BN_LIB);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
if ((pub_key != NULL) && (dh->pub_key == NULL)) BN_free(pub_key);
|
||||
if ((priv_key != NULL) && (dh->priv_key == NULL)) BN_free(priv_key);
|
||||
BN_CTX_free(ctx);
|
||||
return(ok);
|
||||
}
|
||||
|
||||
static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
|
||||
{
|
||||
BN_CTX *ctx;
|
||||
BN_MONT_CTX *mont=NULL;
|
||||
BIGNUM *tmp;
|
||||
int ret= -1;
|
||||
int check_result;
|
||||
|
||||
ctx = BN_CTX_new();
|
||||
if (ctx == NULL) goto err;
|
||||
BN_CTX_start(ctx);
|
||||
tmp = BN_CTX_get(ctx);
|
||||
|
||||
if (dh->priv_key == NULL)
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
DHerr(DH_F_COMPUTE_KEY,DH_R_NO_PRIVATE_VALUE);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (dh->flags & DH_FLAG_CACHE_MONT_P)
|
||||
{
|
||||
mont = BN_MONT_CTX_set_locked(&dh->method_mont_p,
|
||||
CRYPTO_LOCK_DH, dh->p, ctx);
|
||||
if ((dh->flags & DH_FLAG_NO_EXP_CONSTTIME) == 0)
|
||||
{
|
||||
/* XXX */
|
||||
BN_set_flags(dh->priv_key, BN_FLG_EXP_CONSTTIME);
|
||||
}
|
||||
if (!mont)
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!DH_check_pub_key(dh, pub_key, &check_result) || check_result)
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
DHerr(DH_F_COMPUTE_KEY,DH_R_INVALID_PUBKEY);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!dh->meth->bn_mod_exp(dh, tmp, pub_key, dh->priv_key,dh->p,ctx,mont))
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
DHerr(DH_F_COMPUTE_KEY,ERR_R_BN_LIB);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret=BN_bn2bin(tmp,key);
|
||||
err:
|
||||
if (ctx != NULL)
|
||||
{
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int dh_bn_mod_exp(const DH *dh, BIGNUM *r,
|
||||
const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx,
|
||||
BN_MONT_CTX *m_ctx)
|
||||
{
|
||||
/* If a is only one word long and constant time is false, use the faster
|
||||
* exponenentiation function.
|
||||
*/
|
||||
if (a->top == 1 && ((dh->flags & DH_FLAG_NO_EXP_CONSTTIME) != 0))
|
||||
{
|
||||
BN_ULONG A = a->d[0];
|
||||
return BN_mod_exp_mont_word(r,A,p,m,ctx,m_ctx);
|
||||
}
|
||||
else
|
||||
return BN_mod_exp_mont(r,a,p,m,ctx,m_ctx);
|
||||
}
|
||||
|
||||
|
||||
static int dh_init(DH *dh)
|
||||
{
|
||||
dh->flags |= DH_FLAG_CACHE_MONT_P;
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int dh_finish(DH *dh)
|
||||
{
|
||||
if(dh->method_mont_p)
|
||||
BN_MONT_CTX_free(dh->method_mont_p);
|
||||
return(1);
|
||||
}
|
265
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/dh/dh_lib.c
Executable file
265
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/dh/dh_lib.c
Executable file
@ -0,0 +1,265 @@
|
||||
/* crypto/dh/dh_lib.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/dh.h>
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
#include <openssl/engine.h>
|
||||
#endif
|
||||
|
||||
const char *DH_version="Diffie-Hellman" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
static const DH_METHOD *default_DH_method = NULL;
|
||||
|
||||
void DH_set_default_method(const DH_METHOD *meth)
|
||||
{
|
||||
default_DH_method = meth;
|
||||
}
|
||||
|
||||
const DH_METHOD *DH_get_default_method(void)
|
||||
{
|
||||
if(!default_DH_method)
|
||||
default_DH_method = DH_OpenSSL();
|
||||
return default_DH_method;
|
||||
}
|
||||
|
||||
int DH_set_method(DH *dh, const DH_METHOD *meth)
|
||||
{
|
||||
/* NB: The caller is specifically setting a method, so it's not up to us
|
||||
* to deal with which ENGINE it comes from. */
|
||||
const DH_METHOD *mtmp;
|
||||
mtmp = dh->meth;
|
||||
if (mtmp->finish) mtmp->finish(dh);
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if (dh->engine)
|
||||
{
|
||||
ENGINE_finish(dh->engine);
|
||||
dh->engine = NULL;
|
||||
}
|
||||
#endif
|
||||
dh->meth = meth;
|
||||
if (meth->init) meth->init(dh);
|
||||
return 1;
|
||||
}
|
||||
|
||||
DH *DH_new(void)
|
||||
{
|
||||
return DH_new_method(NULL);
|
||||
}
|
||||
|
||||
DH *DH_new_method(ENGINE *engine)
|
||||
{
|
||||
DH *ret;
|
||||
|
||||
ret=(DH *)OPENSSL_malloc(sizeof(DH));
|
||||
if (ret == NULL)
|
||||
{printf("<<-----------------%s %d------------------>>\n", __FUNCTION__, __LINE__);
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
DHerr(DH_F_DH_NEW_METHOD,ERR_R_MALLOC_FAILURE);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
ret->meth = DH_get_default_method();
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if (engine)
|
||||
{
|
||||
if (!ENGINE_init(engine))
|
||||
{
|
||||
DHerr(DH_F_DH_NEW_METHOD, ERR_R_ENGINE_LIB);
|
||||
OPENSSL_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
ret->engine = engine;
|
||||
}
|
||||
else
|
||||
ret->engine = ENGINE_get_default_DH();
|
||||
if(ret->engine)
|
||||
{
|
||||
ret->meth = ENGINE_get_DH(ret->engine);
|
||||
if(!ret->meth)
|
||||
{
|
||||
DHerr(DH_F_DH_NEW_METHOD,ERR_R_ENGINE_LIB);
|
||||
ENGINE_finish(ret->engine);
|
||||
OPENSSL_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ret->pad=0;
|
||||
ret->version=0;
|
||||
ret->p=NULL;
|
||||
ret->g=NULL;
|
||||
ret->length=0;
|
||||
ret->pub_key=NULL;
|
||||
ret->priv_key=NULL;
|
||||
ret->q=NULL;
|
||||
ret->j=NULL;
|
||||
ret->seed = NULL;
|
||||
ret->seedlen = 0;
|
||||
ret->counter = NULL;
|
||||
ret->method_mont_p=NULL;
|
||||
ret->references = 1;
|
||||
ret->flags=ret->meth->flags;
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
if ((ret->meth->init != NULL) && !ret->meth->init(ret))
|
||||
{
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if (ret->engine)
|
||||
ENGINE_finish(ret->engine);
|
||||
#endif
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
OPENSSL_free(ret);
|
||||
printf("<<-----------------%s %d------------------>>\n", __FUNCTION__, __LINE__);
|
||||
ret=NULL;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
void DH_free(DH *r)
|
||||
{
|
||||
int i;
|
||||
if(r == NULL) return;
|
||||
i = CRYPTO_add(&r->references, -1, CRYPTO_LOCK_DH);
|
||||
#ifdef REF_PRINT
|
||||
REF_PRINT("DH",r);
|
||||
#endif
|
||||
if (i > 0) return;
|
||||
#ifdef REF_CHECK
|
||||
if (i < 0)
|
||||
{
|
||||
fprintf(stderr,"DH_free, bad reference count\n");
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (r->meth->finish)
|
||||
r->meth->finish(r);
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if (r->engine)
|
||||
ENGINE_finish(r->engine);
|
||||
#endif
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, r, &r->ex_data);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
if (r->p != NULL) BN_clear_free(r->p);
|
||||
if (r->g != NULL) BN_clear_free(r->g);
|
||||
if (r->q != NULL) BN_clear_free(r->q);
|
||||
if (r->j != NULL) BN_clear_free(r->j);
|
||||
if (r->seed) OPENSSL_free(r->seed);
|
||||
if (r->counter != NULL) BN_clear_free(r->counter);
|
||||
if (r->pub_key != NULL) BN_clear_free(r->pub_key);
|
||||
if (r->priv_key != NULL) BN_clear_free(r->priv_key);
|
||||
OPENSSL_free(r);
|
||||
}
|
||||
|
||||
int DH_up_ref(DH *r)
|
||||
{
|
||||
int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_DH);
|
||||
#ifdef REF_PRINT
|
||||
REF_PRINT("DH",r);
|
||||
#endif
|
||||
#ifdef REF_CHECK
|
||||
if (i < 2)
|
||||
{
|
||||
fprintf(stderr, "DH_up, bad reference count\n");
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
return ((i > 1) ? 1 : 0);
|
||||
}
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
|
||||
CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
|
||||
{
|
||||
return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DH, argl, argp,
|
||||
new_func, dup_func, free_func);
|
||||
}
|
||||
|
||||
int DH_set_ex_data(DH *d, int idx, void *arg)
|
||||
{
|
||||
return(CRYPTO_set_ex_data(&d->ex_data,idx,arg));
|
||||
}
|
||||
|
||||
void *DH_get_ex_data(DH *d, int idx)
|
||||
{
|
||||
return(CRYPTO_get_ex_data(&d->ex_data,idx));
|
||||
}
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
int DH_size(const DH *dh)
|
||||
{
|
||||
return(BN_num_bytes(dh->p));
|
||||
}
|
342
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/evp/digest.c
Executable file
342
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/evp/digest.c
Executable file
@ -0,0 +1,342 @@
|
||||
/* crypto/evp/digest.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2001 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).
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#include <openssl/objects.h>
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
#include <openssl/evp.h>
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
#include <openssl/engine.h>
|
||||
#endif
|
||||
|
||||
void EVP_MD_CTX_init(EVP_MD_CTX *ctx)
|
||||
{
|
||||
memset(ctx,'\0',sizeof *ctx);
|
||||
}
|
||||
|
||||
EVP_MD_CTX *EVP_MD_CTX_create(void)
|
||||
{
|
||||
EVP_MD_CTX *ctx=OPENSSL_malloc(sizeof *ctx);
|
||||
|
||||
EVP_MD_CTX_init(ctx);
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
|
||||
{
|
||||
EVP_MD_CTX_init(ctx);
|
||||
return EVP_DigestInit_ex(ctx, type, NULL);
|
||||
}
|
||||
|
||||
int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
|
||||
{
|
||||
EVP_MD_CTX_clear_flags(ctx,EVP_MD_CTX_FLAG_CLEANED);
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
/* Whether it's nice or not, "Inits" can be used on "Final"'d contexts
|
||||
* so this context may already have an ENGINE! Try to avoid releasing
|
||||
* the previous handle, re-querying for an ENGINE, and having a
|
||||
* reinitialisation, when it may all be unecessary. */
|
||||
if (ctx->engine && ctx->digest && (!type ||
|
||||
(type && (type->type == ctx->digest->type))))
|
||||
goto skip_to_init;
|
||||
if (type)
|
||||
{
|
||||
/* Ensure an ENGINE left lying around from last time is cleared
|
||||
* (the previous check attempted to avoid this if the same
|
||||
* ENGINE and EVP_MD could be used). */
|
||||
if(ctx->engine)
|
||||
ENGINE_finish(ctx->engine);
|
||||
if(impl)
|
||||
{
|
||||
if (!ENGINE_init(impl))
|
||||
{
|
||||
EVPerr(EVP_F_EVP_DIGESTINIT_EX,EVP_R_INITIALIZATION_ERROR);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* Ask if an ENGINE is reserved for this job */
|
||||
impl = ENGINE_get_digest_engine(type->type);
|
||||
if(impl)
|
||||
{
|
||||
/* There's an ENGINE for this job ... (apparently) */
|
||||
const EVP_MD *d = ENGINE_get_digest(impl, type->type);
|
||||
if(!d)
|
||||
{
|
||||
/* Same comment from evp_enc.c */
|
||||
EVPerr(EVP_F_EVP_DIGESTINIT_EX,EVP_R_INITIALIZATION_ERROR);
|
||||
return 0;
|
||||
}
|
||||
/* We'll use the ENGINE's private digest definition */
|
||||
type = d;
|
||||
/* Store the ENGINE functional reference so we know
|
||||
* 'type' came from an ENGINE and we need to release
|
||||
* it when done. */
|
||||
ctx->engine = impl;
|
||||
}
|
||||
else
|
||||
ctx->engine = NULL;
|
||||
}
|
||||
else
|
||||
if(!ctx->digest)
|
||||
{
|
||||
EVPerr(EVP_F_EVP_DIGESTINIT_EX,EVP_R_NO_DIGEST_SET);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
if (ctx->digest != type)
|
||||
{
|
||||
if (ctx->digest && ctx->digest->ctx_size)
|
||||
OPENSSL_free(ctx->md_data);
|
||||
ctx->digest=type;
|
||||
if (type->ctx_size)
|
||||
ctx->md_data=OPENSSL_malloc(type->ctx_size);
|
||||
}
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
skip_to_init:
|
||||
#endif
|
||||
return ctx->digest->init(ctx);
|
||||
}
|
||||
|
||||
int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data,
|
||||
size_t count)
|
||||
{
|
||||
return ctx->digest->update(ctx,data,count);
|
||||
}
|
||||
|
||||
/* The caller can assume that this removes any secret data from the context */
|
||||
int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
|
||||
{
|
||||
int ret;
|
||||
ret = EVP_DigestFinal_ex(ctx, md, size);
|
||||
EVP_MD_CTX_cleanup(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* The caller can assume that this removes any secret data from the context */
|
||||
int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
|
||||
{
|
||||
int ret;
|
||||
|
||||
OPENSSL_assert(ctx->digest->md_size <= EVP_MAX_MD_SIZE);
|
||||
ret=ctx->digest->final(ctx,md);
|
||||
if (size != NULL)
|
||||
*size=ctx->digest->md_size;
|
||||
if (ctx->digest->cleanup)
|
||||
{
|
||||
ctx->digest->cleanup(ctx);
|
||||
EVP_MD_CTX_set_flags(ctx,EVP_MD_CTX_FLAG_CLEANED);
|
||||
}
|
||||
memset(ctx->md_data,0,ctx->digest->ctx_size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in)
|
||||
{
|
||||
EVP_MD_CTX_init(out);
|
||||
return EVP_MD_CTX_copy_ex(out, in);
|
||||
}
|
||||
|
||||
int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
|
||||
{
|
||||
unsigned char *tmp_buf;
|
||||
if ((in == NULL) || (in->digest == NULL))
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
EVPerr(EVP_F_EVP_MD_CTX_COPY_EX,EVP_R_INPUT_NOT_INITIALIZED);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
return 0;
|
||||
}
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
/* Make sure it's safe to copy a digest context using an ENGINE */
|
||||
if (in->engine && !ENGINE_init(in->engine))
|
||||
{
|
||||
EVPerr(EVP_F_EVP_MD_CTX_COPY_EX,ERR_R_ENGINE_LIB);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (out->digest == in->digest)
|
||||
{
|
||||
tmp_buf = out->md_data;
|
||||
EVP_MD_CTX_set_flags(out,EVP_MD_CTX_FLAG_REUSE);
|
||||
}
|
||||
else tmp_buf = NULL;
|
||||
EVP_MD_CTX_cleanup(out);
|
||||
memcpy(out,in,sizeof *out);
|
||||
|
||||
if (out->digest->ctx_size)
|
||||
{
|
||||
if (tmp_buf) out->md_data = tmp_buf;
|
||||
else out->md_data=OPENSSL_malloc(out->digest->ctx_size);
|
||||
memcpy(out->md_data,in->md_data,out->digest->ctx_size);
|
||||
}
|
||||
|
||||
if (out->digest->copy)
|
||||
return out->digest->copy(out,in);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int EVP_Digest(const void *data, size_t count,
|
||||
unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl)
|
||||
{
|
||||
EVP_MD_CTX ctx;
|
||||
int ret;
|
||||
|
||||
EVP_MD_CTX_init(&ctx);
|
||||
EVP_MD_CTX_set_flags(&ctx,EVP_MD_CTX_FLAG_ONESHOT);
|
||||
ret=EVP_DigestInit_ex(&ctx, type, impl)
|
||||
&& EVP_DigestUpdate(&ctx, data, count)
|
||||
&& EVP_DigestFinal_ex(&ctx, md, size);
|
||||
EVP_MD_CTX_cleanup(&ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx)
|
||||
{
|
||||
EVP_MD_CTX_cleanup(ctx);
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
|
||||
/* This call frees resources associated with the context */
|
||||
int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
|
||||
{
|
||||
/* Don't assume ctx->md_data was cleaned in EVP_Digest_Final,
|
||||
* because sometimes only copies of the context are ever finalised.
|
||||
*/
|
||||
if (ctx->digest && ctx->digest->cleanup
|
||||
&& !EVP_MD_CTX_test_flags(ctx,EVP_MD_CTX_FLAG_CLEANED))
|
||||
ctx->digest->cleanup(ctx);
|
||||
if (ctx->digest && ctx->digest->ctx_size && ctx->md_data
|
||||
&& !EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_REUSE))
|
||||
{
|
||||
OPENSSL_cleanse(ctx->md_data,ctx->digest->ctx_size);
|
||||
OPENSSL_free(ctx->md_data);
|
||||
}
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if(ctx->engine)
|
||||
/* The EVP_MD we used belongs to an ENGINE, release the
|
||||
* functional reference we held for this reason. */
|
||||
ENGINE_finish(ctx->engine);
|
||||
#endif
|
||||
memset(ctx,'\0',sizeof *ctx);
|
||||
|
||||
return 1;
|
||||
}
|
503
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/evp/evp_enc.c
Executable file
503
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/evp/evp_enc.c
Executable file
@ -0,0 +1,503 @@
|
||||
/* crypto/evp/evp_enc.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
//#include "cryptlib.h"
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/cryptlib.h>
|
||||
#include <openssl/evp.h>
|
||||
//#include <openssl/err.h>
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
#include <openssl/engine.h>
|
||||
#endif
|
||||
#include <openssl/evp_locl.h>
|
||||
//#include "evp_locl.h"
|
||||
|
||||
const char *EVP_version="EVP" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx)
|
||||
{
|
||||
memset(ctx,0,sizeof(EVP_CIPHER_CTX));
|
||||
/* ctx->cipher=NULL; */
|
||||
}
|
||||
|
||||
int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl,
|
||||
const unsigned char *key, const unsigned char *iv, int enc)
|
||||
{
|
||||
if (enc == -1)
|
||||
enc = ctx->encrypt;
|
||||
else
|
||||
{
|
||||
if (enc)
|
||||
enc = 1;
|
||||
ctx->encrypt = enc;
|
||||
}
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
/* Whether it's nice or not, "Inits" can be used on "Final"'d contexts
|
||||
* so this context may already have an ENGINE! Try to avoid releasing
|
||||
* the previous handle, re-querying for an ENGINE, and having a
|
||||
* reinitialisation, when it may all be unecessary. */
|
||||
if (ctx->engine && ctx->cipher && (!cipher ||
|
||||
(cipher && (cipher->nid == ctx->cipher->nid))))
|
||||
goto skip_to_init;
|
||||
#endif
|
||||
if (cipher)
|
||||
{
|
||||
/* Ensure a context left lying around from last time is cleared
|
||||
* (the previous check attempted to avoid this if the same
|
||||
* ENGINE and EVP_CIPHER could be used). */
|
||||
EVP_CIPHER_CTX_cleanup(ctx);
|
||||
|
||||
/* Restore encrypt field: it is zeroed by cleanup */
|
||||
ctx->encrypt = enc;
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if(impl)
|
||||
{
|
||||
if (!ENGINE_init(impl))
|
||||
{
|
||||
//EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_INITIALIZATION_ERROR);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* Ask if an ENGINE is reserved for this job */
|
||||
impl = ENGINE_get_cipher_engine(cipher->nid);
|
||||
if(impl)
|
||||
{
|
||||
/* There's an ENGINE for this job ... (apparently) */
|
||||
const EVP_CIPHER *c = ENGINE_get_cipher(impl, cipher->nid);
|
||||
if(!c)
|
||||
{
|
||||
/* One positive side-effect of US's export
|
||||
* control history, is that we should at least
|
||||
* be able to avoid using US mispellings of
|
||||
* "initialisation"? */
|
||||
//EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_INITIALIZATION_ERROR);
|
||||
return 0;
|
||||
}
|
||||
/* We'll use the ENGINE's private cipher definition */
|
||||
cipher = c;
|
||||
/* Store the ENGINE functional reference so we know
|
||||
* 'cipher' came from an ENGINE and we need to release
|
||||
* it when done. */
|
||||
ctx->engine = impl;
|
||||
}
|
||||
else
|
||||
ctx->engine = NULL;
|
||||
#endif
|
||||
ctx->cipher=cipher;
|
||||
if (ctx->cipher->ctx_size)
|
||||
{
|
||||
ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size);
|
||||
if (!ctx->cipher_data)
|
||||
{
|
||||
//EVPerr(EVP_F_EVP_CIPHERINIT, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx->cipher_data = NULL;
|
||||
}
|
||||
ctx->key_len = cipher->key_len;
|
||||
ctx->flags = 0;
|
||||
if(ctx->cipher->flags & EVP_CIPH_CTRL_INIT)
|
||||
{
|
||||
if(!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL))
|
||||
{
|
||||
//EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_INITIALIZATION_ERROR);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!ctx->cipher)
|
||||
{
|
||||
//EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_NO_CIPHER_SET);
|
||||
return 0;
|
||||
}
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
skip_to_init:
|
||||
#endif
|
||||
/* we assume block size is a power of 2 in *cryptUpdate */
|
||||
OPENSSL_assert(ctx->cipher->block_size == 1
|
||||
|| ctx->cipher->block_size == 8
|
||||
|| ctx->cipher->block_size == 16);
|
||||
|
||||
if(!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) {
|
||||
switch(EVP_CIPHER_CTX_mode(ctx)) {
|
||||
|
||||
case EVP_CIPH_STREAM_CIPHER:
|
||||
case EVP_CIPH_ECB_MODE:
|
||||
break;
|
||||
|
||||
case EVP_CIPH_CFB_MODE:
|
||||
case EVP_CIPH_OFB_MODE:
|
||||
|
||||
ctx->num = 0;
|
||||
|
||||
case EVP_CIPH_CBC_MODE:
|
||||
|
||||
OPENSSL_assert(EVP_CIPHER_CTX_iv_length(ctx) <= sizeof ctx->iv);
|
||||
if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx));
|
||||
memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx));
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef OPENSSL_FIPS
|
||||
/* After 'key' is set no further parameters changes are permissible.
|
||||
* So only check for non FIPS enabling at this point.
|
||||
*/
|
||||
if (key && FIPS_mode())
|
||||
{
|
||||
if (!(ctx->cipher->flags & EVP_CIPH_FLAG_FIPS)
|
||||
& !(ctx->flags & EVP_CIPH_FLAG_NON_FIPS_ALLOW))
|
||||
{
|
||||
//EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_DISABLED_FOR_FIPS);
|
||||
ERR_add_error_data(2, "cipher=",
|
||||
EVP_CIPHER_name(ctx->cipher));
|
||||
ctx->cipher = &bad_cipher;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if(key || (ctx->cipher->flags & EVP_CIPH_ALWAYS_CALL_INIT)) {
|
||||
if(!ctx->cipher->init(ctx,key,iv,enc)) return 0;
|
||||
}
|
||||
ctx->buf_len=0;
|
||||
ctx->final_used=0;
|
||||
ctx->block_mask=ctx->cipher->block_size-1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
||||
const unsigned char *key, const unsigned char *iv, int enc)
|
||||
{
|
||||
if (cipher)
|
||||
{
|
||||
EVP_CIPHER_CTX_init(ctx);
|
||||
}
|
||||
return EVP_CipherInit_ex(ctx,cipher,NULL,key,iv,enc);
|
||||
}
|
||||
|
||||
int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
||||
const unsigned char *key, const unsigned char *iv)
|
||||
{
|
||||
return EVP_CipherInit(ctx, cipher, key, iv, 1);
|
||||
}
|
||||
|
||||
int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
|
||||
const unsigned char *in, int inl)
|
||||
{
|
||||
int i,j,bl;
|
||||
|
||||
OPENSSL_assert(inl > 0);
|
||||
if(ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0)
|
||||
{
|
||||
if(ctx->cipher->do_cipher(ctx,out,in,inl))
|
||||
{
|
||||
*outl=inl;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*outl=0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
i=ctx->buf_len;
|
||||
bl=ctx->cipher->block_size;
|
||||
OPENSSL_assert(bl <= sizeof ctx->buf);
|
||||
if (i != 0)
|
||||
{
|
||||
if (i+inl < bl)
|
||||
{
|
||||
memcpy(&(ctx->buf[i]),in,inl);
|
||||
ctx->buf_len+=inl;
|
||||
*outl=0;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
j=bl-i;
|
||||
memcpy(&(ctx->buf[i]),in,j);
|
||||
if(!ctx->cipher->do_cipher(ctx,out,ctx->buf,bl)) return 0;
|
||||
inl-=j;
|
||||
in+=j;
|
||||
out+=bl;
|
||||
*outl=bl;
|
||||
}
|
||||
}
|
||||
else
|
||||
*outl = 0;
|
||||
i=inl&(bl-1);
|
||||
inl-=i;
|
||||
if (inl > 0)
|
||||
{
|
||||
if(!ctx->cipher->do_cipher(ctx,out,in,inl)) return 0;
|
||||
*outl+=inl;
|
||||
}
|
||||
|
||||
if (i != 0)
|
||||
memcpy(ctx->buf,&(in[inl]),i);
|
||||
ctx->buf_len=i;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
|
||||
{
|
||||
int ret;
|
||||
ret = EVP_EncryptFinal_ex(ctx, out, outl);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
|
||||
{
|
||||
int i,n,b,bl,ret;
|
||||
|
||||
b=ctx->cipher->block_size;
|
||||
OPENSSL_assert(b <= sizeof ctx->buf);
|
||||
if (b == 1)
|
||||
{
|
||||
*outl=0;
|
||||
return 1;
|
||||
}
|
||||
bl=ctx->buf_len;
|
||||
if (ctx->flags & EVP_CIPH_NO_PADDING)
|
||||
{
|
||||
if(bl)
|
||||
{
|
||||
//EVPerr(EVP_F_EVP_ENCRYPTFINAL,EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
*outl = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
n=b-bl;
|
||||
for (i=bl; i<b; i++)
|
||||
ctx->buf[i]=n;
|
||||
ret=ctx->cipher->do_cipher(ctx,out,ctx->buf,b);
|
||||
|
||||
|
||||
if(ret)
|
||||
*outl=b;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl,
|
||||
const unsigned char *key, const unsigned char *iv)
|
||||
{
|
||||
return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 0);
|
||||
}
|
||||
|
||||
int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
|
||||
const unsigned char *in, int inl)
|
||||
{
|
||||
int b, fix_len;
|
||||
|
||||
if (inl == 0)
|
||||
{
|
||||
*outl=0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ctx->flags & EVP_CIPH_NO_PADDING)
|
||||
return EVP_EncryptUpdate(ctx, out, outl, in, inl);
|
||||
|
||||
b=ctx->cipher->block_size;
|
||||
OPENSSL_assert(b <= sizeof ctx->final);
|
||||
|
||||
if(ctx->final_used)
|
||||
{
|
||||
memcpy(out,ctx->final,b);
|
||||
out+=b;
|
||||
fix_len = 1;
|
||||
}
|
||||
else
|
||||
fix_len = 0;
|
||||
|
||||
|
||||
if(!EVP_EncryptUpdate(ctx,out,outl,in,inl))
|
||||
return 0;
|
||||
|
||||
/* if we have 'decrypted' a multiple of block size, make sure
|
||||
* we have a copy of this last block */
|
||||
if (b > 1 && !ctx->buf_len)
|
||||
{
|
||||
*outl-=b;
|
||||
ctx->final_used=1;
|
||||
memcpy(ctx->final,&out[*outl],b);
|
||||
}
|
||||
else
|
||||
ctx->final_used = 0;
|
||||
|
||||
if (fix_len)
|
||||
*outl += b;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
|
||||
{
|
||||
int ret;
|
||||
ret = EVP_DecryptFinal_ex(ctx, out, outl);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
|
||||
{
|
||||
int i,b;
|
||||
int n;
|
||||
|
||||
*outl=0;
|
||||
b=ctx->cipher->block_size;
|
||||
if (ctx->flags & EVP_CIPH_NO_PADDING)
|
||||
{
|
||||
if(ctx->buf_len)
|
||||
{
|
||||
//EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
*outl = 0;
|
||||
return 1;
|
||||
}
|
||||
if (b > 1)
|
||||
{
|
||||
printf("Decrypt blocksize %d\n",b);
|
||||
if (ctx->buf_len || !ctx->final_used)
|
||||
{
|
||||
//EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_WRONG_FINAL_BLOCK_LENGTH);
|
||||
return(0);
|
||||
}
|
||||
OPENSSL_assert(b <= sizeof ctx->final);
|
||||
n=ctx->final[b-1];
|
||||
printf("Decrypt n %d\n",n);
|
||||
if (n > b)
|
||||
{
|
||||
//EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_BAD_DECRYPT);
|
||||
return(0);
|
||||
}
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
if (ctx->final[--b] != n)
|
||||
{
|
||||
//EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_BAD_DECRYPT);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
n=ctx->cipher->block_size-n;
|
||||
for (i=0; i<n; i++)
|
||||
out[i]=ctx->final[i];
|
||||
*outl=n;
|
||||
}
|
||||
else
|
||||
*outl=0;
|
||||
return(1);
|
||||
}
|
||||
|
||||
int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
|
||||
{
|
||||
if (c->cipher != NULL)
|
||||
{
|
||||
if(c->cipher->cleanup && !c->cipher->cleanup(c))
|
||||
return 0;
|
||||
/* Cleanse cipher context data */
|
||||
if (c->cipher_data)
|
||||
OPENSSL_cleanse(c->cipher_data, c->cipher->ctx_size);
|
||||
}
|
||||
if (c->cipher_data)
|
||||
OPENSSL_free(c->cipher_data);
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if (c->engine)
|
||||
/* The EVP_CIPHER we used belongs to an ENGINE, release the
|
||||
* functional reference we held for this reason. */
|
||||
ENGINE_finish(c->engine);
|
||||
#endif
|
||||
memset(c,0,sizeof(EVP_CIPHER_CTX));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
|
||||
{
|
||||
int ret;
|
||||
if(!ctx->cipher) {
|
||||
//EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_NO_CIPHER_SET);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!ctx->cipher->ctrl) {
|
||||
//EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_CTRL_NOT_IMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = ctx->cipher->ctrl(ctx, type, arg, ptr);
|
||||
if(ret == -1) {
|
||||
//EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
210
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/evp/m_sha1.c
Executable file
210
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/evp/m_sha1.c
Executable file
@ -0,0 +1,210 @@
|
||||
/* crypto/evp/m_sha1.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cryptlib.h"
|
||||
|
||||
#ifndef OPENSSL_NO_SHA
|
||||
|
||||
#include <openssl/evp.h>
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#include <openssl/objects.h>
|
||||
#include <openssl/x509.h>
|
||||
#endif
|
||||
#include <openssl/obj_mac.h>
|
||||
#include <openssl/sha.h>
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
#include <openssl/rsa.h>
|
||||
#endif
|
||||
|
||||
static int init(EVP_MD_CTX *ctx)
|
||||
{ return SHA1_Init(ctx->md_data); }
|
||||
|
||||
static int update(EVP_MD_CTX *ctx,const void *data,size_t count)
|
||||
{ return SHA1_Update(ctx->md_data,data,count); }
|
||||
|
||||
static int final(EVP_MD_CTX *ctx,unsigned char *md)
|
||||
{ return SHA1_Final(md,ctx->md_data); }
|
||||
|
||||
static const EVP_MD sha1_md=
|
||||
{
|
||||
NID_sha1,
|
||||
NID_sha1WithRSAEncryption,
|
||||
SHA_DIGEST_LENGTH,
|
||||
0,
|
||||
init,
|
||||
update,
|
||||
final,
|
||||
NULL,
|
||||
NULL,
|
||||
EVP_PKEY_RSA_method,
|
||||
SHA_CBLOCK,
|
||||
sizeof(EVP_MD *)+sizeof(SHA_CTX),
|
||||
};
|
||||
|
||||
const EVP_MD *EVP_sha1(void)
|
||||
{
|
||||
return(&sha1_md);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_SHA256
|
||||
static int init224(EVP_MD_CTX *ctx)
|
||||
{ return SHA224_Init(ctx->md_data); }
|
||||
static int init256(EVP_MD_CTX *ctx)
|
||||
{ return SHA256_Init(ctx->md_data); }
|
||||
/*
|
||||
* Even though there're separate SHA224_[Update|Final], we call
|
||||
* SHA256 functions even in SHA224 context. This is what happens
|
||||
* there anyway, so we can spare few CPU cycles:-)
|
||||
*/
|
||||
static int update256(EVP_MD_CTX *ctx,const void *data,size_t count)
|
||||
{ return SHA256_Update(ctx->md_data,data,count); }
|
||||
static int final256(EVP_MD_CTX *ctx,unsigned char *md)
|
||||
{ return SHA256_Final(md,ctx->md_data); }
|
||||
|
||||
static const EVP_MD sha224_md=
|
||||
{
|
||||
NID_sha224,
|
||||
NID_sha224WithRSAEncryption,
|
||||
SHA224_DIGEST_LENGTH,
|
||||
0,
|
||||
init224,
|
||||
update256,
|
||||
final256,
|
||||
NULL,
|
||||
NULL,
|
||||
EVP_PKEY_RSA_method,
|
||||
SHA256_CBLOCK,
|
||||
sizeof(EVP_MD *)+sizeof(SHA256_CTX),
|
||||
};
|
||||
|
||||
const EVP_MD *EVP_sha224(void)
|
||||
{ return(&sha224_md); }
|
||||
|
||||
static const EVP_MD sha256_md=
|
||||
{
|
||||
NID_sha256,
|
||||
NID_sha256WithRSAEncryption,
|
||||
SHA256_DIGEST_LENGTH,
|
||||
0,
|
||||
init256,
|
||||
update256,
|
||||
final256,
|
||||
NULL,
|
||||
NULL,
|
||||
EVP_PKEY_RSA_method,
|
||||
SHA256_CBLOCK,
|
||||
sizeof(EVP_MD *)+sizeof(SHA256_CTX),
|
||||
};
|
||||
|
||||
const EVP_MD *EVP_sha256(void)
|
||||
{ return(&sha256_md); }
|
||||
#endif /* ifndef OPENSSL_NO_SHA256 */
|
||||
|
||||
#ifndef OPENSSL_NO_SHA512
|
||||
static int init384(EVP_MD_CTX *ctx)
|
||||
{ return SHA384_Init(ctx->md_data); }
|
||||
static int init512(EVP_MD_CTX *ctx)
|
||||
{ return SHA512_Init(ctx->md_data); }
|
||||
/* See comment in SHA224/256 section */
|
||||
static int update512(EVP_MD_CTX *ctx,const void *data,size_t count)
|
||||
{ return SHA512_Update(ctx->md_data,data,count); }
|
||||
static int final512(EVP_MD_CTX *ctx,unsigned char *md)
|
||||
{ return SHA512_Final(md,ctx->md_data); }
|
||||
|
||||
static const EVP_MD sha384_md=
|
||||
{
|
||||
NID_sha384,
|
||||
NID_sha384WithRSAEncryption,
|
||||
SHA384_DIGEST_LENGTH,
|
||||
0,
|
||||
init384,
|
||||
update512,
|
||||
final512,
|
||||
NULL,
|
||||
NULL,
|
||||
EVP_PKEY_RSA_method,
|
||||
SHA512_CBLOCK,
|
||||
sizeof(EVP_MD *)+sizeof(SHA512_CTX),
|
||||
};
|
||||
|
||||
const EVP_MD *EVP_sha384(void)
|
||||
{ return(&sha384_md); }
|
||||
|
||||
static const EVP_MD sha512_md=
|
||||
{
|
||||
NID_sha512,
|
||||
NID_sha512WithRSAEncryption,
|
||||
SHA512_DIGEST_LENGTH,
|
||||
0,
|
||||
init512,
|
||||
update512,
|
||||
final512,
|
||||
NULL,
|
||||
NULL,
|
||||
EVP_PKEY_RSA_method,
|
||||
SHA512_CBLOCK,
|
||||
sizeof(EVP_MD *)+sizeof(SHA512_CTX),
|
||||
};
|
||||
|
||||
const EVP_MD *EVP_sha512(void)
|
||||
{ return(&sha512_md); }
|
||||
#endif /* ifndef OPENSSL_NO_SHA512 */
|
173
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/hmac/hmac.c
Executable file
173
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/hmac/hmac.c
Executable file
@ -0,0 +1,173 @@
|
||||
/* crypto/hmac/hmac.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/hmac.h>
|
||||
|
||||
void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
|
||||
const EVP_MD *md, ENGINE *impl)
|
||||
{
|
||||
int i,j,reset=0;
|
||||
unsigned char pad[HMAC_MAX_MD_CBLOCK];
|
||||
|
||||
if (md != NULL)
|
||||
{
|
||||
reset=1;
|
||||
ctx->md=md;
|
||||
}
|
||||
else
|
||||
md=ctx->md;
|
||||
|
||||
if (key != NULL)
|
||||
{
|
||||
reset=1;
|
||||
j=EVP_MD_block_size(md);
|
||||
OPENSSL_assert(j <= (int)sizeof(ctx->key));
|
||||
if (j < len)
|
||||
{
|
||||
EVP_DigestInit_ex(&ctx->md_ctx,md, impl);
|
||||
EVP_DigestUpdate(&ctx->md_ctx,key,len);
|
||||
EVP_DigestFinal_ex(&(ctx->md_ctx),ctx->key,
|
||||
&ctx->key_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
OPENSSL_assert(len>=0 && len<=(int)sizeof(ctx->key));
|
||||
memcpy(ctx->key,key,len);
|
||||
ctx->key_length=len;
|
||||
}
|
||||
if(ctx->key_length != HMAC_MAX_MD_CBLOCK)
|
||||
memset(&ctx->key[ctx->key_length], 0,
|
||||
HMAC_MAX_MD_CBLOCK - ctx->key_length);
|
||||
}
|
||||
|
||||
if (reset)
|
||||
{
|
||||
for (i=0; i<HMAC_MAX_MD_CBLOCK; i++)
|
||||
pad[i]=0x36^ctx->key[i];
|
||||
EVP_DigestInit_ex(&ctx->i_ctx,md, impl);
|
||||
EVP_DigestUpdate(&ctx->i_ctx,pad,EVP_MD_block_size(md));
|
||||
|
||||
for (i=0; i<HMAC_MAX_MD_CBLOCK; i++)
|
||||
pad[i]=0x5c^ctx->key[i];
|
||||
EVP_DigestInit_ex(&ctx->o_ctx,md, impl);
|
||||
EVP_DigestUpdate(&ctx->o_ctx,pad,EVP_MD_block_size(md));
|
||||
}
|
||||
EVP_MD_CTX_copy_ex(&ctx->md_ctx,&ctx->i_ctx);
|
||||
}
|
||||
|
||||
void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
|
||||
const EVP_MD *md)
|
||||
{
|
||||
if(key && md)
|
||||
HMAC_CTX_init(ctx);
|
||||
HMAC_Init_ex(ctx,key,len,md, NULL);
|
||||
}
|
||||
|
||||
void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len)
|
||||
{
|
||||
EVP_DigestUpdate(&ctx->md_ctx,data,len);
|
||||
}
|
||||
|
||||
void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len)
|
||||
{
|
||||
int j;
|
||||
unsigned int i;
|
||||
unsigned char buf[EVP_MAX_MD_SIZE];
|
||||
|
||||
j=EVP_MD_block_size(ctx->md);
|
||||
|
||||
EVP_DigestFinal_ex(&ctx->md_ctx,buf,&i);
|
||||
EVP_MD_CTX_copy_ex(&ctx->md_ctx,&ctx->o_ctx);
|
||||
EVP_DigestUpdate(&ctx->md_ctx,buf,i);
|
||||
EVP_DigestFinal_ex(&ctx->md_ctx,md,len);
|
||||
}
|
||||
|
||||
void HMAC_CTX_init(HMAC_CTX *ctx)
|
||||
{
|
||||
EVP_MD_CTX_init(&ctx->i_ctx);
|
||||
EVP_MD_CTX_init(&ctx->o_ctx);
|
||||
EVP_MD_CTX_init(&ctx->md_ctx);
|
||||
}
|
||||
|
||||
void HMAC_CTX_cleanup(HMAC_CTX *ctx)
|
||||
{
|
||||
EVP_MD_CTX_cleanup(&ctx->i_ctx);
|
||||
EVP_MD_CTX_cleanup(&ctx->o_ctx);
|
||||
EVP_MD_CTX_cleanup(&ctx->md_ctx);
|
||||
memset(ctx,0,sizeof *ctx);
|
||||
}
|
||||
|
||||
unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
|
||||
const unsigned char *d, size_t n, unsigned char *md,
|
||||
unsigned int *md_len)
|
||||
{
|
||||
HMAC_CTX c;
|
||||
static unsigned char m[EVP_MAX_MD_SIZE];
|
||||
|
||||
if (md == NULL) md=m;
|
||||
HMAC_CTX_init(&c);
|
||||
HMAC_Init(&c,key,key_len,evp_md);
|
||||
HMAC_Update(&c,d,n);
|
||||
HMAC_Final(&c,md,md_len);
|
||||
HMAC_CTX_cleanup(&c);
|
||||
return(md);
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
/*================================================
|
||||
Created by: Chris Hsu
|
||||
DATE: 17 Aug. 2006
|
||||
==================================================*/
|
||||
|
||||
//#define _M_AMD64
|
||||
|
||||
|
||||
/*for bothl visual C++ (console) and RSDK*/
|
||||
#define THIRTY_TWO_BIT
|
||||
#define BN_LLONG
|
||||
|
||||
|
||||
#define OPENSSL_NO_ASM
|
||||
|
||||
#define OPENSSL_NO_ENGINE
|
||||
#define GETPID_IS_MEANINGLESS
|
||||
|
||||
#define OPENSSL_NO_RSA
|
||||
#define OPENSSL_NO_BIO
|
||||
#define OPENSSL_NO_DSA
|
||||
#define OPENSSL_NO_EC
|
||||
#define OPENSSL_NO_ECDSA
|
||||
#define OPENSSL_NO_MD2
|
||||
#define OPENSSL_NO_MD4
|
||||
#define OPENSSL_NO_SHA512
|
||||
#define OPENSSL_NO_RIPEMD
|
||||
#define OPENSSL_NO_DES
|
||||
#define OPENSSL_NO_RC4
|
||||
#define OPENSSL_NO_IDEA
|
||||
#define OPENSSL_NO_RC2
|
||||
#define OPENSSL_NO_BF
|
||||
#define OPENSSL_NO_CAST
|
||||
#define OPENSSL_NO_RC5
|
||||
//#define OPENSSL_NO_AES
|
||||
#define OPENSSL_NO_SHA0
|
||||
#define OPENSSL_NO_FP_API
|
||||
#define OPENSSL_NO_LOCKING
|
||||
|
||||
#define OPENSSL_NO_GMP
|
||||
#define OPENSSL_NO_MDC2
|
||||
|
127
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/aes.h
Executable file
127
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/aes.h
Executable file
@ -0,0 +1,127 @@
|
||||
/* crypto/aes/aes.h -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2002 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.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_AES_H
|
||||
#define HEADER_AES_H
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
#ifdef OPENSSL_NO_AES
|
||||
#error AES is disabled.
|
||||
#endif
|
||||
|
||||
#define AES_ENCRYPT 1
|
||||
#define AES_DECRYPT 0
|
||||
|
||||
/* Because array size can't be a const in C, the following two are macros.
|
||||
Both sizes are in bytes. */
|
||||
#define AES_MAXNR 14
|
||||
#define AES_BLOCK_SIZE 16
|
||||
|
||||
#if defined(OPENSSL_FIPS)
|
||||
#define FIPS_AES_SIZE_T int
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* This should be a hidden type, but EVP requires that the size be known */
|
||||
struct aes_key_st {
|
||||
unsigned long rd_key[4 *(AES_MAXNR + 1)];
|
||||
int rounds;
|
||||
};
|
||||
typedef struct aes_key_st AES_KEY;
|
||||
|
||||
const char *AES_options(void);
|
||||
|
||||
int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
|
||||
AES_KEY *key);
|
||||
int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
|
||||
AES_KEY *key);
|
||||
|
||||
void AES_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key);
|
||||
void AES_decrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key);
|
||||
|
||||
void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key, const int enc);
|
||||
void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const AES_KEY *key,
|
||||
unsigned char *ivec, const int enc);
|
||||
void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const AES_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const AES_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const AES_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void AES_cfbr_encrypt_block(const unsigned char *in,unsigned char *out,
|
||||
const int nbits,const AES_KEY *key,
|
||||
unsigned char *ivec,const int enc);
|
||||
void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const AES_KEY *key,
|
||||
unsigned char *ivec, int *num);
|
||||
void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const AES_KEY *key,
|
||||
unsigned char ivec[AES_BLOCK_SIZE],
|
||||
unsigned char ecount_buf[AES_BLOCK_SIZE],
|
||||
unsigned int *num);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !HEADER_AES_H */
|
695
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/bio.h
Executable file
695
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/bio.h
Executable file
@ -0,0 +1,695 @@
|
||||
/* crypto/bio/bio.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BIO_H
|
||||
#define HEADER_BIO_H
|
||||
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* These are the 'types' of BIOs */
|
||||
#define BIO_TYPE_NONE 0
|
||||
#define BIO_TYPE_MEM (1|0x0400)
|
||||
#define BIO_TYPE_FILE (2|0x0400)
|
||||
|
||||
#define BIO_TYPE_FD (4|0x0400|0x0100)
|
||||
#define BIO_TYPE_SOCKET (5|0x0400|0x0100)
|
||||
#define BIO_TYPE_NULL (6|0x0400)
|
||||
#define BIO_TYPE_SSL (7|0x0200)
|
||||
#define BIO_TYPE_MD (8|0x0200) /* passive filter */
|
||||
#define BIO_TYPE_BUFFER (9|0x0200) /* filter */
|
||||
#define BIO_TYPE_CIPHER (10|0x0200) /* filter */
|
||||
#define BIO_TYPE_BASE64 (11|0x0200) /* filter */
|
||||
#define BIO_TYPE_CONNECT (12|0x0400|0x0100) /* socket - connect */
|
||||
#define BIO_TYPE_ACCEPT (13|0x0400|0x0100) /* socket for accept */
|
||||
#define BIO_TYPE_PROXY_CLIENT (14|0x0200) /* client proxy BIO */
|
||||
#define BIO_TYPE_PROXY_SERVER (15|0x0200) /* server proxy BIO */
|
||||
#define BIO_TYPE_NBIO_TEST (16|0x0200) /* server proxy BIO */
|
||||
#define BIO_TYPE_NULL_FILTER (17|0x0200)
|
||||
#define BIO_TYPE_BER (18|0x0200) /* BER -> bin filter */
|
||||
#define BIO_TYPE_BIO (19|0x0400) /* (half a) BIO pair */
|
||||
#define BIO_TYPE_LINEBUFFER (20|0x0200) /* filter */
|
||||
|
||||
#define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */
|
||||
#define BIO_TYPE_FILTER 0x0200
|
||||
#define BIO_TYPE_SOURCE_SINK 0x0400
|
||||
|
||||
/* BIO_FILENAME_READ|BIO_CLOSE to open or close on free.
|
||||
* BIO_set_fp(in,stdin,BIO_NOCLOSE); */
|
||||
#define BIO_NOCLOSE 0x00
|
||||
#define BIO_CLOSE 0x01
|
||||
|
||||
/* These are used in the following macros and are passed to
|
||||
* BIO_ctrl() */
|
||||
#define BIO_CTRL_RESET 1 /* opt - rewind/zero etc */
|
||||
#define BIO_CTRL_EOF 2 /* opt - are we at the eof */
|
||||
#define BIO_CTRL_INFO 3 /* opt - extra tit-bits */
|
||||
#define BIO_CTRL_SET 4 /* man - set the 'IO' type */
|
||||
#define BIO_CTRL_GET 5 /* man - get the 'IO' type */
|
||||
#define BIO_CTRL_PUSH 6 /* opt - internal, used to signify change */
|
||||
#define BIO_CTRL_POP 7 /* opt - internal, used to signify change */
|
||||
#define BIO_CTRL_GET_CLOSE 8 /* man - set the 'close' on free */
|
||||
#define BIO_CTRL_SET_CLOSE 9 /* man - set the 'close' on free */
|
||||
#define BIO_CTRL_PENDING 10 /* opt - is their more data buffered */
|
||||
#define BIO_CTRL_FLUSH 11 /* opt - 'flush' buffered output */
|
||||
#define BIO_CTRL_DUP 12 /* man - extra stuff for 'duped' BIO */
|
||||
#define BIO_CTRL_WPENDING 13 /* opt - number of bytes still to write */
|
||||
/* callback is int cb(BIO *bio,state,ret); */
|
||||
#define BIO_CTRL_SET_CALLBACK 14 /* opt - set callback function */
|
||||
#define BIO_CTRL_GET_CALLBACK 15 /* opt - set callback function */
|
||||
|
||||
#define BIO_CTRL_SET_FILENAME 30 /* BIO_s_file special */
|
||||
|
||||
/* modifiers */
|
||||
#define BIO_FP_READ 0x02
|
||||
#define BIO_FP_WRITE 0x04
|
||||
#define BIO_FP_APPEND 0x08
|
||||
#define BIO_FP_TEXT 0x10
|
||||
|
||||
#define BIO_FLAGS_READ 0x01
|
||||
#define BIO_FLAGS_WRITE 0x02
|
||||
#define BIO_FLAGS_IO_SPECIAL 0x04
|
||||
#define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
|
||||
#define BIO_FLAGS_SHOULD_RETRY 0x08
|
||||
|
||||
/* Used in BIO_gethostbyname() */
|
||||
#define BIO_GHBN_CTRL_HITS 1
|
||||
#define BIO_GHBN_CTRL_MISSES 2
|
||||
#define BIO_GHBN_CTRL_CACHE_SIZE 3
|
||||
#define BIO_GHBN_CTRL_GET_ENTRY 4
|
||||
#define BIO_GHBN_CTRL_FLUSH 5
|
||||
|
||||
/* Mostly used in the SSL BIO */
|
||||
/* Not used anymore
|
||||
* #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10
|
||||
* #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20
|
||||
* #define BIO_FLAGS_PROTOCOL_STARTUP 0x40
|
||||
*/
|
||||
|
||||
#define BIO_FLAGS_BASE64_NO_NL 0x100
|
||||
|
||||
/* This is used with memory BIOs: it means we shouldn't free up or change the
|
||||
* data in any way.
|
||||
*/
|
||||
#define BIO_FLAGS_MEM_RDONLY 0x200
|
||||
|
||||
#define BIO_set_flags(b,f) ((b)->flags|=(f))
|
||||
#define BIO_get_flags(b) ((b)->flags)
|
||||
#define BIO_set_retry_special(b) \
|
||||
((b)->flags|=(BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))
|
||||
#define BIO_set_retry_read(b) \
|
||||
((b)->flags|=(BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))
|
||||
#define BIO_set_retry_write(b) \
|
||||
((b)->flags|=(BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))
|
||||
|
||||
/* These are normally used internally in BIOs */
|
||||
#define BIO_clear_flags(b,f) ((b)->flags&= ~(f))
|
||||
#define BIO_clear_retry_flags(b) \
|
||||
((b)->flags&= ~(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
|
||||
#define BIO_get_retry_flags(b) \
|
||||
((b)->flags&(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
|
||||
|
||||
/* These should be used by the application to tell why we should retry */
|
||||
#define BIO_should_read(a) ((a)->flags & BIO_FLAGS_READ)
|
||||
#define BIO_should_write(a) ((a)->flags & BIO_FLAGS_WRITE)
|
||||
#define BIO_should_io_special(a) ((a)->flags & BIO_FLAGS_IO_SPECIAL)
|
||||
#define BIO_retry_type(a) ((a)->flags & BIO_FLAGS_RWS)
|
||||
#define BIO_should_retry(a) ((a)->flags & BIO_FLAGS_SHOULD_RETRY)
|
||||
|
||||
/* The next three are used in conjunction with the
|
||||
* BIO_should_io_special() condition. After this returns true,
|
||||
* BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO
|
||||
* stack and return the 'reason' for the special and the offending BIO.
|
||||
* Given a BIO, BIO_get_retry_reason(bio) will return the code. */
|
||||
/* Returned from the SSL bio when the certificate retrieval code had an error */
|
||||
#define BIO_RR_SSL_X509_LOOKUP 0x01
|
||||
/* Returned from the connect BIO when a connect would have blocked */
|
||||
#define BIO_RR_CONNECT 0x02
|
||||
/* Returned from the accept BIO when an accept would have blocked */
|
||||
#define BIO_RR_ACCEPT 0x03
|
||||
|
||||
/* These are passed by the BIO callback */
|
||||
#define BIO_CB_FREE 0x01
|
||||
#define BIO_CB_READ 0x02
|
||||
#define BIO_CB_WRITE 0x03
|
||||
#define BIO_CB_PUTS 0x04
|
||||
#define BIO_CB_GETS 0x05
|
||||
#define BIO_CB_CTRL 0x06
|
||||
|
||||
/* The callback is called before and after the underling operation,
|
||||
* The BIO_CB_RETURN flag indicates if it is after the call */
|
||||
#define BIO_CB_RETURN 0x80
|
||||
#define BIO_CB_return(a) ((a)|BIO_CB_RETURN))
|
||||
#define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN))
|
||||
#define BIO_cb_post(a) ((a)&BIO_CB_RETURN)
|
||||
|
||||
#define BIO_set_callback(b,cb) ((b)->callback=(cb))
|
||||
#define BIO_set_callback_arg(b,arg) ((b)->cb_arg=(char *)(arg))
|
||||
#define BIO_get_callback_arg(b) ((b)->cb_arg)
|
||||
#define BIO_get_callback(b) ((b)->callback)
|
||||
#define BIO_method_name(b) ((b)->method->name)
|
||||
#define BIO_method_type(b) ((b)->method->type)
|
||||
|
||||
typedef struct bio_st BIO;
|
||||
|
||||
typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long);
|
||||
|
||||
#ifndef OPENSSL_SYS_WIN16
|
||||
typedef struct bio_method_st
|
||||
{
|
||||
int type;
|
||||
const char *name;
|
||||
int (*bwrite)(BIO *, const char *, int);
|
||||
int (*bread)(BIO *, char *, int);
|
||||
int (*bputs)(BIO *, const char *);
|
||||
int (*bgets)(BIO *, char *, int);
|
||||
long (*ctrl)(BIO *, int, long, void *);
|
||||
int (*create)(BIO *);
|
||||
int (*destroy)(BIO *);
|
||||
long (*callback_ctrl)(BIO *, int, bio_info_cb *);
|
||||
} BIO_METHOD;
|
||||
#else
|
||||
typedef struct bio_method_st
|
||||
{
|
||||
int type;
|
||||
const char *name;
|
||||
int (_far *bwrite)();
|
||||
int (_far *bread)();
|
||||
int (_far *bputs)();
|
||||
int (_far *bgets)();
|
||||
long (_far *ctrl)();
|
||||
int (_far *create)();
|
||||
int (_far *destroy)();
|
||||
long (_far *callback_ctrl)();
|
||||
} BIO_METHOD;
|
||||
#endif
|
||||
|
||||
struct bio_st
|
||||
{
|
||||
BIO_METHOD *method;
|
||||
/* bio, mode, argp, argi, argl, ret */
|
||||
long (*callback)(struct bio_st *,int,const char *,int, long,long);
|
||||
char *cb_arg; /* first argument for the callback */
|
||||
|
||||
int init;
|
||||
int shutdown;
|
||||
int flags; /* extra storage */
|
||||
int retry_reason;
|
||||
int num;
|
||||
void *ptr;
|
||||
struct bio_st *next_bio; /* used by filter BIOs */
|
||||
struct bio_st *prev_bio; /* used by filter BIOs */
|
||||
int references;
|
||||
unsigned long num_read;
|
||||
unsigned long num_write;
|
||||
|
||||
CRYPTO_EX_DATA ex_data;
|
||||
};
|
||||
|
||||
DECLARE_STACK_OF(BIO)
|
||||
|
||||
typedef struct bio_f_buffer_ctx_struct
|
||||
{
|
||||
/* BIO *bio; */ /* this is now in the BIO struct */
|
||||
int ibuf_size; /* how big is the input buffer */
|
||||
int obuf_size; /* how big is the output buffer */
|
||||
|
||||
char *ibuf; /* the char array */
|
||||
int ibuf_len; /* how many bytes are in it */
|
||||
int ibuf_off; /* write/read offset */
|
||||
|
||||
char *obuf; /* the char array */
|
||||
int obuf_len; /* how many bytes are in it */
|
||||
int obuf_off; /* write/read offset */
|
||||
} BIO_F_BUFFER_CTX;
|
||||
|
||||
/* connect BIO stuff */
|
||||
#define BIO_CONN_S_BEFORE 1
|
||||
#define BIO_CONN_S_GET_IP 2
|
||||
#define BIO_CONN_S_GET_PORT 3
|
||||
#define BIO_CONN_S_CREATE_SOCKET 4
|
||||
#define BIO_CONN_S_CONNECT 5
|
||||
#define BIO_CONN_S_OK 6
|
||||
#define BIO_CONN_S_BLOCKED_CONNECT 7
|
||||
#define BIO_CONN_S_NBIO 8
|
||||
/*#define BIO_CONN_get_param_hostname BIO_ctrl */
|
||||
|
||||
#define BIO_C_SET_CONNECT 100
|
||||
#define BIO_C_DO_STATE_MACHINE 101
|
||||
#define BIO_C_SET_NBIO 102
|
||||
#define BIO_C_SET_PROXY_PARAM 103
|
||||
#define BIO_C_SET_FD 104
|
||||
#define BIO_C_GET_FD 105
|
||||
#define BIO_C_SET_FILE_PTR 106
|
||||
#define BIO_C_GET_FILE_PTR 107
|
||||
#define BIO_C_SET_FILENAME 108
|
||||
#define BIO_C_SET_SSL 109
|
||||
#define BIO_C_GET_SSL 110
|
||||
#define BIO_C_SET_MD 111
|
||||
#define BIO_C_GET_MD 112
|
||||
#define BIO_C_GET_CIPHER_STATUS 113
|
||||
#define BIO_C_SET_BUF_MEM 114
|
||||
#define BIO_C_GET_BUF_MEM_PTR 115
|
||||
#define BIO_C_GET_BUFF_NUM_LINES 116
|
||||
#define BIO_C_SET_BUFF_SIZE 117
|
||||
#define BIO_C_SET_ACCEPT 118
|
||||
#define BIO_C_SSL_MODE 119
|
||||
#define BIO_C_GET_MD_CTX 120
|
||||
#define BIO_C_GET_PROXY_PARAM 121
|
||||
#define BIO_C_SET_BUFF_READ_DATA 122 /* data to read first */
|
||||
#define BIO_C_GET_CONNECT 123
|
||||
#define BIO_C_GET_ACCEPT 124
|
||||
#define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125
|
||||
#define BIO_C_GET_SSL_NUM_RENEGOTIATES 126
|
||||
#define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127
|
||||
#define BIO_C_FILE_SEEK 128
|
||||
#define BIO_C_GET_CIPHER_CTX 129
|
||||
#define BIO_C_SET_BUF_MEM_EOF_RETURN 130/*return end of input value*/
|
||||
#define BIO_C_SET_BIND_MODE 131
|
||||
#define BIO_C_GET_BIND_MODE 132
|
||||
#define BIO_C_FILE_TELL 133
|
||||
#define BIO_C_GET_SOCKS 134
|
||||
#define BIO_C_SET_SOCKS 135
|
||||
|
||||
#define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */
|
||||
#define BIO_C_GET_WRITE_BUF_SIZE 137
|
||||
#define BIO_C_MAKE_BIO_PAIR 138
|
||||
#define BIO_C_DESTROY_BIO_PAIR 139
|
||||
#define BIO_C_GET_WRITE_GUARANTEE 140
|
||||
#define BIO_C_GET_READ_REQUEST 141
|
||||
#define BIO_C_SHUTDOWN_WR 142
|
||||
#define BIO_C_NREAD0 143
|
||||
#define BIO_C_NREAD 144
|
||||
#define BIO_C_NWRITE0 145
|
||||
#define BIO_C_NWRITE 146
|
||||
#define BIO_C_RESET_READ_REQUEST 147
|
||||
#define BIO_C_SET_MD_CTX 148
|
||||
|
||||
|
||||
#define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg)
|
||||
#define BIO_get_app_data(s) BIO_get_ex_data(s,0)
|
||||
|
||||
/* BIO_s_connect() and BIO_s_socks4a_connect() */
|
||||
#define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name)
|
||||
#define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port)
|
||||
#define BIO_set_conn_ip(b,ip) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip)
|
||||
#define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port)
|
||||
#define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)
|
||||
#define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)
|
||||
#define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)
|
||||
#define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3)
|
||||
|
||||
|
||||
#define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
|
||||
|
||||
/* BIO_s_accept_socket() */
|
||||
#define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name)
|
||||
#define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)
|
||||
/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */
|
||||
#define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?"a":NULL)
|
||||
#define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio)
|
||||
|
||||
#define BIO_BIND_NORMAL 0
|
||||
#define BIO_BIND_REUSEADDR_IF_UNUSED 1
|
||||
#define BIO_BIND_REUSEADDR 2
|
||||
#define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)
|
||||
#define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)
|
||||
|
||||
#define BIO_do_connect(b) BIO_do_handshake(b)
|
||||
#define BIO_do_accept(b) BIO_do_handshake(b)
|
||||
#define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)
|
||||
|
||||
/* BIO_s_proxy_client() */
|
||||
#define BIO_set_url(b,url) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url))
|
||||
#define BIO_set_proxies(b,p) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p))
|
||||
/* BIO_set_nbio(b,n) */
|
||||
#define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s))
|
||||
/* BIO *BIO_get_filter_bio(BIO *bio); */
|
||||
#define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)()))
|
||||
#define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk)
|
||||
#define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool)
|
||||
|
||||
#define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp)
|
||||
#define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p))
|
||||
#define BIO_get_url(b,url) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url))
|
||||
#define BIO_get_no_connect_return(b) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL)
|
||||
|
||||
#define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)
|
||||
#define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c)
|
||||
|
||||
#define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp)
|
||||
#define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp)
|
||||
|
||||
#define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)
|
||||
#define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)
|
||||
|
||||
/* name is cast to lose const, but might be better to route through a function
|
||||
so we can do it safely */
|
||||
#ifdef CONST_STRICT
|
||||
/* If you are wondering why this isn't defined, its because CONST_STRICT is
|
||||
* purely a compile-time kludge to allow const to be checked.
|
||||
*/
|
||||
int BIO_read_filename(BIO *b,const char *name);
|
||||
#else
|
||||
#define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||
BIO_CLOSE|BIO_FP_READ,(char *)name)
|
||||
#endif
|
||||
#define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||
BIO_CLOSE|BIO_FP_WRITE,name)
|
||||
#define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||
BIO_CLOSE|BIO_FP_APPEND,name)
|
||||
#define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
|
||||
BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)
|
||||
|
||||
/* WARNING WARNING, this ups the reference count on the read bio of the
|
||||
* SSL structure. This is because the ssl read BIO is now pointed to by
|
||||
* the next_bio field in the bio. So when you free the BIO, make sure
|
||||
* you are doing a BIO_free_all() to catch the underlying BIO. */
|
||||
#define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl)
|
||||
#define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp)
|
||||
#define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)
|
||||
#define BIO_set_ssl_renegotiate_bytes(b,num) \
|
||||
BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL);
|
||||
#define BIO_get_num_renegotiates(b) \
|
||||
BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL);
|
||||
#define BIO_set_ssl_renegotiate_timeout(b,seconds) \
|
||||
BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL);
|
||||
|
||||
/* defined in evp.h */
|
||||
/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */
|
||||
|
||||
#define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)
|
||||
#define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm)
|
||||
#define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp)
|
||||
#define BIO_set_mem_eof_return(b,v) \
|
||||
BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)
|
||||
|
||||
/* For the BIO_f_buffer() type */
|
||||
#define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)
|
||||
#define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)
|
||||
#define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)
|
||||
#define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)
|
||||
#define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)
|
||||
|
||||
/* Don't use the next one unless you know what you are doing :-) */
|
||||
#define BIO_dup_state(b,ret) BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))
|
||||
|
||||
#define BIO_reset(b) (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)
|
||||
#define BIO_eof(b) (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)
|
||||
#define BIO_set_close(b,c) (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)
|
||||
#define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)
|
||||
#define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)
|
||||
#define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)
|
||||
/* ...pending macros have inappropriate return type */
|
||||
size_t BIO_ctrl_pending(BIO *b);
|
||||
size_t BIO_ctrl_wpending(BIO *b);
|
||||
#define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
|
||||
#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \
|
||||
cbp)
|
||||
#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)
|
||||
|
||||
/* For the BIO_f_buffer() type */
|
||||
#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
|
||||
|
||||
/* For BIO_s_bio() */
|
||||
#define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)
|
||||
#define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)
|
||||
#define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)
|
||||
#define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)
|
||||
#define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)
|
||||
/* macros with inappropriate type -- but ...pending macros use int too: */
|
||||
#define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)
|
||||
#define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
|
||||
size_t BIO_ctrl_get_write_guarantee(BIO *b);
|
||||
size_t BIO_ctrl_get_read_request(BIO *b);
|
||||
int BIO_ctrl_reset_read_request(BIO *b);
|
||||
|
||||
/* These two aren't currently implemented */
|
||||
/* int BIO_get_ex_num(BIO *bio); */
|
||||
/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */
|
||||
int BIO_set_ex_data(BIO *bio,int idx,void *data);
|
||||
void *BIO_get_ex_data(BIO *bio,int idx);
|
||||
int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
|
||||
CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
|
||||
unsigned long BIO_number_read(BIO *bio);
|
||||
unsigned long BIO_number_written(BIO *bio);
|
||||
|
||||
# ifndef OPENSSL_NO_FP_API
|
||||
# if defined(OPENSSL_SYS_WIN16) && defined(_WINDLL)
|
||||
BIO_METHOD *BIO_s_file_internal(void);
|
||||
BIO *BIO_new_file_internal(char *filename, char *mode);
|
||||
BIO *BIO_new_fp_internal(FILE *stream, int close_flag);
|
||||
# define BIO_s_file BIO_s_file_internal
|
||||
# define BIO_new_file BIO_new_file_internal
|
||||
# define BIO_new_fp BIO_new_fp_internal
|
||||
# else /* FP_API */
|
||||
BIO_METHOD *BIO_s_file(void );
|
||||
BIO *BIO_new_file(const char *filename, const char *mode);
|
||||
BIO *BIO_new_fp(FILE *stream, int close_flag);
|
||||
# define BIO_s_file_internal BIO_s_file
|
||||
# define BIO_new_file_internal BIO_new_file
|
||||
# define BIO_new_fp_internal BIO_s_file
|
||||
# endif /* FP_API */
|
||||
# endif
|
||||
BIO * BIO_new(BIO_METHOD *type);
|
||||
int BIO_set(BIO *a,BIO_METHOD *type);
|
||||
int BIO_free(BIO *a);
|
||||
void BIO_vfree(BIO *a);
|
||||
int BIO_read(BIO *b, void *data, int len);
|
||||
int BIO_gets(BIO *bp,char *buf, int size);
|
||||
int BIO_write(BIO *b, const void *data, int len);
|
||||
int BIO_puts(BIO *bp,const char *buf);
|
||||
int BIO_indent(BIO *b,int indent,int max);
|
||||
long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg);
|
||||
long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long));
|
||||
char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg);
|
||||
long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg);
|
||||
BIO * BIO_push(BIO *b,BIO *append);
|
||||
BIO * BIO_pop(BIO *b);
|
||||
void BIO_free_all(BIO *a);
|
||||
BIO * BIO_find_type(BIO *b,int bio_type);
|
||||
BIO * BIO_next(BIO *b);
|
||||
BIO * BIO_get_retry_BIO(BIO *bio, int *reason);
|
||||
int BIO_get_retry_reason(BIO *bio);
|
||||
BIO * BIO_dup_chain(BIO *in);
|
||||
|
||||
int BIO_nread0(BIO *bio, char **buf);
|
||||
int BIO_nread(BIO *bio, char **buf, int num);
|
||||
int BIO_nwrite0(BIO *bio, char **buf);
|
||||
int BIO_nwrite(BIO *bio, char **buf, int num);
|
||||
|
||||
#ifndef OPENSSL_SYS_WIN16
|
||||
long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
|
||||
long argl,long ret);
|
||||
#else
|
||||
long _far _loadds BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
|
||||
long argl,long ret);
|
||||
#endif
|
||||
|
||||
BIO_METHOD *BIO_s_mem(void);
|
||||
BIO *BIO_new_mem_buf(void *buf, int len);
|
||||
BIO_METHOD *BIO_s_socket(void);
|
||||
BIO_METHOD *BIO_s_connect(void);
|
||||
BIO_METHOD *BIO_s_accept(void);
|
||||
BIO_METHOD *BIO_s_fd(void);
|
||||
#ifndef OPENSSL_SYS_OS2
|
||||
BIO_METHOD *BIO_s_log(void);
|
||||
#endif
|
||||
BIO_METHOD *BIO_s_bio(void);
|
||||
BIO_METHOD *BIO_s_null(void);
|
||||
BIO_METHOD *BIO_f_null(void);
|
||||
BIO_METHOD *BIO_f_buffer(void);
|
||||
#ifdef OPENSSL_SYS_VMS
|
||||
BIO_METHOD *BIO_f_linebuffer(void);
|
||||
#endif
|
||||
BIO_METHOD *BIO_f_nbio_test(void);
|
||||
/* BIO_METHOD *BIO_f_ber(void); */
|
||||
|
||||
int BIO_sock_should_retry(int i);
|
||||
int BIO_sock_non_fatal_error(int error);
|
||||
int BIO_fd_should_retry(int i);
|
||||
int BIO_fd_non_fatal_error(int error);
|
||||
int BIO_dump(BIO *b,const char *bytes,int len);
|
||||
int BIO_dump_indent(BIO *b,const char *bytes,int len,int indent);
|
||||
|
||||
struct hostent *BIO_gethostbyname(const char *name);
|
||||
/* We might want a thread-safe interface too:
|
||||
* struct hostent *BIO_gethostbyname_r(const char *name,
|
||||
* struct hostent *result, void *buffer, size_t buflen);
|
||||
* or something similar (caller allocates a struct hostent,
|
||||
* pointed to by "result", and additional buffer space for the various
|
||||
* substructures; if the buffer does not suffice, NULL is returned
|
||||
* and an appropriate error code is set).
|
||||
*/
|
||||
int BIO_sock_error(int sock);
|
||||
int BIO_socket_ioctl(int fd, long type, void *arg);
|
||||
int BIO_socket_nbio(int fd,int mode);
|
||||
int BIO_get_port(const char *str, unsigned short *port_ptr);
|
||||
int BIO_get_host_ip(const char *str, unsigned char *ip);
|
||||
int BIO_get_accept_socket(char *host_port,int mode);
|
||||
int BIO_accept(int sock,char **ip_port);
|
||||
int BIO_sock_init(void );
|
||||
void BIO_sock_cleanup(void);
|
||||
int BIO_set_tcp_ndelay(int sock,int turn_on);
|
||||
|
||||
BIO *BIO_new_socket(int sock, int close_flag);
|
||||
BIO *BIO_new_fd(int fd, int close_flag);
|
||||
BIO *BIO_new_connect(char *host_port);
|
||||
BIO *BIO_new_accept(char *host_port);
|
||||
|
||||
int BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
|
||||
BIO **bio2, size_t writebuf2);
|
||||
/* If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.
|
||||
* Otherwise returns 0 and sets *bio1 and *bio2 to NULL.
|
||||
* Size 0 uses default value.
|
||||
*/
|
||||
|
||||
void BIO_copy_next_retry(BIO *b);
|
||||
|
||||
/*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/
|
||||
|
||||
int BIO_printf(BIO *bio, const char *format, ...);
|
||||
int BIO_vprintf(BIO *bio, const char *format, va_list args);
|
||||
int BIO_snprintf(char *buf, size_t n, const char *format, ...);
|
||||
int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args);
|
||||
|
||||
/* 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_BIO_strings(void);
|
||||
|
||||
/* Error codes for the BIO functions. */
|
||||
|
||||
/* Function codes. */
|
||||
#define BIO_F_ACPT_STATE 100
|
||||
#define BIO_F_BIO_ACCEPT 101
|
||||
#define BIO_F_BIO_BER_GET_HEADER 102
|
||||
#define BIO_F_BIO_CTRL 103
|
||||
#define BIO_F_BIO_GETHOSTBYNAME 120
|
||||
#define BIO_F_BIO_GETS 104
|
||||
#define BIO_F_BIO_GET_ACCEPT_SOCKET 105
|
||||
#define BIO_F_BIO_GET_HOST_IP 106
|
||||
#define BIO_F_BIO_GET_PORT 107
|
||||
#define BIO_F_BIO_MAKE_PAIR 121
|
||||
#define BIO_F_BIO_NEW 108
|
||||
#define BIO_F_BIO_NEW_FILE 109
|
||||
#define BIO_F_BIO_NEW_MEM_BUF 126
|
||||
#define BIO_F_BIO_NREAD 123
|
||||
#define BIO_F_BIO_NREAD0 124
|
||||
#define BIO_F_BIO_NWRITE 125
|
||||
#define BIO_F_BIO_NWRITE0 122
|
||||
#define BIO_F_BIO_PUTS 110
|
||||
#define BIO_F_BIO_READ 111
|
||||
#define BIO_F_BIO_SOCK_INIT 112
|
||||
#define BIO_F_BIO_WRITE 113
|
||||
#define BIO_F_BUFFER_CTRL 114
|
||||
#define BIO_F_CONN_CTRL 127
|
||||
#define BIO_F_CONN_STATE 115
|
||||
#define BIO_F_FILE_CTRL 116
|
||||
#define BIO_F_FILE_READ 130
|
||||
#define BIO_F_LINEBUFFER_CTRL 129
|
||||
#define BIO_F_MEM_READ 128
|
||||
#define BIO_F_MEM_WRITE 117
|
||||
#define BIO_F_SSL_NEW 118
|
||||
#define BIO_F_WSASTARTUP 119
|
||||
|
||||
/* Reason codes. */
|
||||
#define BIO_R_ACCEPT_ERROR 100
|
||||
#define BIO_R_BAD_FOPEN_MODE 101
|
||||
#define BIO_R_BAD_HOSTNAME_LOOKUP 102
|
||||
#define BIO_R_BROKEN_PIPE 124
|
||||
#define BIO_R_CONNECT_ERROR 103
|
||||
#define BIO_R_EOF_ON_MEMORY_BIO 127
|
||||
#define BIO_R_ERROR_SETTING_NBIO 104
|
||||
#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105
|
||||
#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106
|
||||
#define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107
|
||||
#define BIO_R_INVALID_ARGUMENT 125
|
||||
#define BIO_R_INVALID_IP_ADDRESS 108
|
||||
#define BIO_R_IN_USE 123
|
||||
#define BIO_R_KEEPALIVE 109
|
||||
#define BIO_R_NBIO_CONNECT_ERROR 110
|
||||
#define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111
|
||||
#define BIO_R_NO_HOSTNAME_SPECIFIED 112
|
||||
#define BIO_R_NO_PORT_DEFINED 113
|
||||
#define BIO_R_NO_PORT_SPECIFIED 114
|
||||
#define BIO_R_NO_SUCH_FILE 128
|
||||
#define BIO_R_NULL_PARAMETER 115
|
||||
#define BIO_R_TAG_MISMATCH 116
|
||||
#define BIO_R_UNABLE_TO_BIND_SOCKET 117
|
||||
#define BIO_R_UNABLE_TO_CREATE_SOCKET 118
|
||||
#define BIO_R_UNABLE_TO_LISTEN_SOCKET 119
|
||||
#define BIO_R_UNINITIALIZED 120
|
||||
#define BIO_R_UNSUPPORTED_METHOD 121
|
||||
#define BIO_R_WRITE_TO_READ_ONLY_BIO 126
|
||||
#define BIO_R_WSASTARTUP 122
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
842
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/bn.h
Executable file
842
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/bn.h
Executable file
@ -0,0 +1,842 @@
|
||||
/* crypto/bn/bn.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
*
|
||||
* Portions of the attached software ("Contribution") are developed by
|
||||
* SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
|
||||
*
|
||||
* The Contribution is licensed pursuant to the Eric Young open source
|
||||
* license provided above.
|
||||
*
|
||||
* The binary polynomial arithmetic software is originally written by
|
||||
* Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BN_H
|
||||
#define HEADER_BN_H
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
#include <stdio.h> /* FILE */
|
||||
#endif
|
||||
#include <openssl/ossl_typ.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* These preprocessor symbols control various aspects of the bignum headers and
|
||||
* library code. They're not defined by any "normal" configuration, as they are
|
||||
* intended for development and testing purposes. NB: defining all three can be
|
||||
* useful for debugging application code as well as openssl itself.
|
||||
*
|
||||
* BN_DEBUG - turn on various debugging alterations to the bignum code
|
||||
* BN_DEBUG_RAND - uses random poisoning of unused words to trip up
|
||||
* mismanagement of bignum internals. You must also define BN_DEBUG.
|
||||
*/
|
||||
/* #define BN_DEBUG */
|
||||
/* #define BN_DEBUG_RAND */
|
||||
|
||||
#define BN_MUL_COMBA
|
||||
#define BN_SQR_COMBA
|
||||
|
||||
/*Begin: comment out to save memory consumption, 17Aug2006, Chris */
|
||||
#if 0
|
||||
#define BN_RECURSION
|
||||
#endif
|
||||
/*End: comment out to save memory consumption , 17Aug2006, Chris */
|
||||
|
||||
/* This next option uses the C libraries (2 word)/(1 word) function.
|
||||
* If it is not defined, I use my C version (which is slower).
|
||||
* The reason for this flag is that when the particular C compiler
|
||||
* library routine is used, and the library is linked with a different
|
||||
* compiler, the library is missing. This mostly happens when the
|
||||
* library is built with gcc and then linked using normal cc. This would
|
||||
* be a common occurrence because gcc normally produces code that is
|
||||
* 2 times faster than system compilers for the big number stuff.
|
||||
* For machines with only one compiler (or shared libraries), this should
|
||||
* be on. Again this in only really a problem on machines
|
||||
* using "long long's", are 32bit, and are not using my assembler code. */
|
||||
#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \
|
||||
defined(OPENSSL_SYS_WIN32) || defined(linux)
|
||||
# ifndef BN_DIV2W
|
||||
# define BN_DIV2W
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* assuming long is 64bit - this is the DEC Alpha
|
||||
* unsigned long long is only 64 bits :-(, don't define
|
||||
* BN_LLONG for the DEC Alpha */
|
||||
#ifdef SIXTY_FOUR_BIT_LONG
|
||||
#define BN_ULLONG unsigned long long
|
||||
#define BN_ULONG unsigned long
|
||||
#define BN_LONG long
|
||||
#define BN_BITS 128
|
||||
#define BN_BYTES 8
|
||||
#define BN_BITS2 64
|
||||
#define BN_BITS4 32
|
||||
#define BN_MASK (0xffffffffffffffffffffffffffffffffLL)
|
||||
#define BN_MASK2 (0xffffffffffffffffL)
|
||||
#define BN_MASK2l (0xffffffffL)
|
||||
#define BN_MASK2h (0xffffffff00000000L)
|
||||
#define BN_MASK2h1 (0xffffffff80000000L)
|
||||
#define BN_TBIT (0x8000000000000000L)
|
||||
#define BN_DEC_CONV (10000000000000000000UL)
|
||||
#define BN_DEC_FMT1 "%lu"
|
||||
#define BN_DEC_FMT2 "%019lu"
|
||||
#define BN_DEC_NUM 19
|
||||
#endif
|
||||
|
||||
/* This is where the long long data type is 64 bits, but long is 32.
|
||||
* For machines where there are 64bit registers, this is the mode to use.
|
||||
* IRIX, on R4000 and above should use this mode, along with the relevant
|
||||
* assembler code :-). Do NOT define BN_LLONG.
|
||||
*/
|
||||
#ifdef SIXTY_FOUR_BIT
|
||||
#undef BN_LLONG
|
||||
#undef BN_ULLONG
|
||||
#define BN_ULONG unsigned long long
|
||||
#define BN_LONG long long
|
||||
#define BN_BITS 128
|
||||
#define BN_BYTES 8
|
||||
#define BN_BITS2 64
|
||||
#define BN_BITS4 32
|
||||
#define BN_MASK2 (0xffffffffffffffffLL)
|
||||
#define BN_MASK2l (0xffffffffL)
|
||||
#define BN_MASK2h (0xffffffff00000000LL)
|
||||
#define BN_MASK2h1 (0xffffffff80000000LL)
|
||||
#define BN_TBIT (0x8000000000000000LL)
|
||||
#define BN_DEC_CONV (10000000000000000000ULL)
|
||||
#define BN_DEC_FMT1 "%llu"
|
||||
#define BN_DEC_FMT2 "%019llu"
|
||||
#define BN_DEC_NUM 19
|
||||
#endif
|
||||
|
||||
#ifdef THIRTY_TWO_BIT
|
||||
#ifdef BN_LLONG
|
||||
# if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__)
|
||||
# define BN_ULLONG unsigned __int64
|
||||
# else
|
||||
# define BN_ULLONG unsigned long long
|
||||
# endif
|
||||
#endif
|
||||
#define BN_ULONG unsigned int
|
||||
#define BN_LONG int
|
||||
#define BN_BITS 64
|
||||
#define BN_BYTES 4
|
||||
#define BN_BITS2 32
|
||||
#define BN_BITS4 16
|
||||
#ifdef OPENSSL_SYS_WIN32
|
||||
/* VC++ doesn't like the LL suffix */
|
||||
#define BN_MASK (0xffffffffffffffffL)
|
||||
#else
|
||||
#define BN_MASK (0xffffffffffffffffLL)
|
||||
#endif
|
||||
#define BN_MASK2 (0xffffffffL)
|
||||
#define BN_MASK2l (0xffff)
|
||||
#define BN_MASK2h1 (0xffff8000L)
|
||||
#define BN_MASK2h (0xffff0000L)
|
||||
#define BN_TBIT (0x80000000L)
|
||||
#define BN_DEC_CONV (1000000000L)
|
||||
#define BN_DEC_FMT1 "%lu"
|
||||
#define BN_DEC_FMT2 "%09lu"
|
||||
#define BN_DEC_NUM 9
|
||||
#endif
|
||||
|
||||
#ifdef SIXTEEN_BIT
|
||||
#ifndef BN_DIV2W
|
||||
#define BN_DIV2W
|
||||
#endif
|
||||
#define BN_ULLONG unsigned long
|
||||
#define BN_ULONG unsigned short
|
||||
#define BN_LONG short
|
||||
#define BN_BITS 32
|
||||
#define BN_BYTES 2
|
||||
#define BN_BITS2 16
|
||||
#define BN_BITS4 8
|
||||
#define BN_MASK (0xffffffff)
|
||||
#define BN_MASK2 (0xffff)
|
||||
#define BN_MASK2l (0xff)
|
||||
#define BN_MASK2h1 (0xff80)
|
||||
#define BN_MASK2h (0xff00)
|
||||
#define BN_TBIT (0x8000)
|
||||
#define BN_DEC_CONV (100000)
|
||||
#define BN_DEC_FMT1 "%u"
|
||||
#define BN_DEC_FMT2 "%05u"
|
||||
#define BN_DEC_NUM 5
|
||||
#endif
|
||||
|
||||
#ifdef EIGHT_BIT
|
||||
#ifndef BN_DIV2W
|
||||
#define BN_DIV2W
|
||||
#endif
|
||||
#define BN_ULLONG unsigned short
|
||||
#define BN_ULONG unsigned char
|
||||
#define BN_LONG char
|
||||
#define BN_BITS 16
|
||||
#define BN_BYTES 1
|
||||
#define BN_BITS2 8
|
||||
#define BN_BITS4 4
|
||||
#define BN_MASK (0xffff)
|
||||
#define BN_MASK2 (0xff)
|
||||
#define BN_MASK2l (0xf)
|
||||
#define BN_MASK2h1 (0xf8)
|
||||
#define BN_MASK2h (0xf0)
|
||||
#define BN_TBIT (0x80)
|
||||
#define BN_DEC_CONV (100)
|
||||
#define BN_DEC_FMT1 "%u"
|
||||
#define BN_DEC_FMT2 "%02u"
|
||||
#define BN_DEC_NUM 2
|
||||
#endif
|
||||
|
||||
#define BN_DEFAULT_BITS 1280
|
||||
|
||||
#define BN_FLG_MALLOCED 0x01
|
||||
#define BN_FLG_STATIC_DATA 0x02
|
||||
#define BN_FLG_EXP_CONSTTIME 0x04 /* avoid leaking exponent information through timings
|
||||
* (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime) */
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
#define BN_FLG_FREE 0x8000 /* used for debuging */
|
||||
#endif
|
||||
#define BN_set_flags(b,n) ((b)->flags|=(n))
|
||||
#define BN_get_flags(b,n) ((b)->flags&(n))
|
||||
|
||||
/* get a clone of a BIGNUM with changed flags, for *temporary* use only
|
||||
* (the two BIGNUMs cannot not be used in parallel!) */
|
||||
#define BN_with_flags(dest,b,n) ((dest)->d=(b)->d, \
|
||||
(dest)->top=(b)->top, \
|
||||
(dest)->dmax=(b)->dmax, \
|
||||
(dest)->neg=(b)->neg, \
|
||||
(dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \
|
||||
| ((b)->flags & ~BN_FLG_MALLOCED) \
|
||||
| BN_FLG_STATIC_DATA \
|
||||
| (n)))
|
||||
|
||||
/* Already declared in ossl_typ.h */
|
||||
#if 0
|
||||
typedef struct bignum_st BIGNUM;
|
||||
/* Used for temp variables (declaration hidden in bn_lcl.h) */
|
||||
typedef struct bignum_ctx BN_CTX;
|
||||
typedef struct bn_blinding_st BN_BLINDING;
|
||||
typedef struct bn_mont_ctx_st BN_MONT_CTX;
|
||||
typedef struct bn_recp_ctx_st BN_RECP_CTX;
|
||||
typedef struct bn_gencb_st BN_GENCB;
|
||||
#endif
|
||||
|
||||
struct bignum_st
|
||||
{
|
||||
BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */
|
||||
int top; /* Index of last used d +1. */
|
||||
/* The next are internal book keeping for bn_expand. */
|
||||
int dmax; /* Size of the d array. */
|
||||
int neg; /* one if the number is negative */
|
||||
int flags;
|
||||
};
|
||||
|
||||
/* Used for montgomery multiplication */
|
||||
struct bn_mont_ctx_st
|
||||
{
|
||||
int ri; /* number of bits in R */
|
||||
BIGNUM RR; /* used to convert to montgomery form */
|
||||
BIGNUM N; /* The modulus */
|
||||
BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1
|
||||
* (Ni is only stored for bignum algorithm) */
|
||||
BN_ULONG n0; /* least significant word of Ni */
|
||||
int flags;
|
||||
};
|
||||
|
||||
/* Used for reciprocal division/mod functions
|
||||
* It cannot be shared between threads
|
||||
*/
|
||||
struct bn_recp_ctx_st
|
||||
{
|
||||
BIGNUM N; /* the divisor */
|
||||
BIGNUM Nr; /* the reciprocal */
|
||||
int num_bits;
|
||||
int shift;
|
||||
int flags;
|
||||
};
|
||||
|
||||
/* Used for slow "generation" functions. */
|
||||
struct bn_gencb_st
|
||||
{
|
||||
unsigned int ver; /* To handle binary (in)compatibility */
|
||||
void *arg; /* callback-specific data */
|
||||
union
|
||||
{
|
||||
/* if(ver==1) - handles old style callbacks */
|
||||
void (*cb_1)(int, int, void *);
|
||||
/* if(ver==2) - new callback style */
|
||||
int (*cb_2)(int, int, BN_GENCB *);
|
||||
} cb;
|
||||
};
|
||||
/* Wrapper function to make using BN_GENCB easier, */
|
||||
int BN_GENCB_call(BN_GENCB *cb, int a, int b);
|
||||
|
||||
/* Macro to populate a BN_GENCB structure with an "old"-style callback */
|
||||
#define BN_GENCB_set_old(gencb, callback, cb_arg) { \
|
||||
BN_GENCB *tmp_gencb = (gencb); \
|
||||
tmp_gencb->ver = 1; \
|
||||
tmp_gencb->arg = (cb_arg); \
|
||||
tmp_gencb->cb.cb_1 = (callback); }
|
||||
/* Macro to populate a BN_GENCB structure with a "new"-style callback */
|
||||
#define BN_GENCB_set(gencb, callback, cb_arg) { \
|
||||
BN_GENCB *tmp_gencb = (gencb); \
|
||||
tmp_gencb->ver = 2; \
|
||||
tmp_gencb->arg = (cb_arg); \
|
||||
tmp_gencb->cb.cb_2 = (callback); }
|
||||
|
||||
#define BN_prime_checks 0 /* default: select number of iterations
|
||||
based on the size of the number */
|
||||
|
||||
/* number of Miller-Rabin iterations for an error rate of less than 2^-80
|
||||
* for random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook
|
||||
* of Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996];
|
||||
* original paper: Damgaard, Landrock, Pomerance: Average case error estimates
|
||||
* for the strong probable prime test. -- Math. Comp. 61 (1993) 177-194) */
|
||||
#define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \
|
||||
(b) >= 850 ? 3 : \
|
||||
(b) >= 650 ? 4 : \
|
||||
(b) >= 550 ? 5 : \
|
||||
(b) >= 450 ? 6 : \
|
||||
(b) >= 400 ? 7 : \
|
||||
(b) >= 350 ? 8 : \
|
||||
(b) >= 300 ? 9 : \
|
||||
(b) >= 250 ? 12 : \
|
||||
(b) >= 200 ? 15 : \
|
||||
(b) >= 150 ? 18 : \
|
||||
/* b >= 100 */ 27)
|
||||
|
||||
#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
|
||||
|
||||
/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */
|
||||
#define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \
|
||||
(((w) == 0) && ((a)->top == 0)))
|
||||
#define BN_is_zero(a) ((a)->top == 0)
|
||||
#define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg)
|
||||
#define BN_is_word(a,w) (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg))
|
||||
#define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1))
|
||||
|
||||
#define BN_one(a) (BN_set_word((a),1))
|
||||
#define BN_zero_ex(a) \
|
||||
do { \
|
||||
BIGNUM *_tmp_bn = (a); \
|
||||
_tmp_bn->top = 0; \
|
||||
_tmp_bn->neg = 0; \
|
||||
} while(0)
|
||||
#ifdef OPENSSL_NO_DEPRECATED
|
||||
#define BN_zero(a) BN_zero_ex(a)
|
||||
#else
|
||||
#define BN_zero(a) (BN_set_word((a),0))
|
||||
#endif
|
||||
|
||||
const BIGNUM *BN_value_one(void);
|
||||
char * BN_options(void);
|
||||
BN_CTX *BN_CTX_new(void);
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
void BN_CTX_init(BN_CTX *c);
|
||||
#endif
|
||||
void BN_CTX_free(BN_CTX *c);
|
||||
void BN_CTX_start(BN_CTX *ctx);
|
||||
BIGNUM *BN_CTX_get(BN_CTX *ctx);
|
||||
void BN_CTX_end(BN_CTX *ctx);
|
||||
int BN_rand(BIGNUM *rnd, int bits, int top,int bottom);
|
||||
int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom);
|
||||
int BN_rand_range(BIGNUM *rnd, BIGNUM *range);
|
||||
int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range);
|
||||
int BN_num_bits(const BIGNUM *a);
|
||||
int BN_num_bits_word(BN_ULONG);
|
||||
BIGNUM *BN_new(void);
|
||||
void BN_init(BIGNUM *);
|
||||
void BN_clear_free(BIGNUM *a);
|
||||
BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
|
||||
void BN_swap(BIGNUM *a, BIGNUM *b);
|
||||
BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret);
|
||||
int BN_bn2bin(const BIGNUM *a, unsigned char *to);
|
||||
BIGNUM *BN_mpi2bn(const unsigned char *s,int len,BIGNUM *ret);
|
||||
int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
|
||||
int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
|
||||
int BN_sqr(BIGNUM *r, const BIGNUM *a,BN_CTX *ctx);
|
||||
/** BN_set_negative sets sign of a BIGNUM
|
||||
* \param b pointer to the BIGNUM object
|
||||
* \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise
|
||||
*/
|
||||
void BN_set_negative(BIGNUM *b, int n);
|
||||
/** BN_is_negative returns 1 if the BIGNUM is negative
|
||||
* \param a pointer to the BIGNUM object
|
||||
* \return 1 if a < 0 and 0 otherwise
|
||||
*/
|
||||
#define BN_is_negative(a) ((a)->neg != 0)
|
||||
|
||||
int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
|
||||
BN_CTX *ctx);
|
||||
#define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx))
|
||||
int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);
|
||||
int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m);
|
||||
int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m);
|
||||
int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m);
|
||||
int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m);
|
||||
|
||||
BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
|
||||
BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_mul_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_add_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_sub_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_set_word(BIGNUM *a, BN_ULONG w);
|
||||
BN_ULONG BN_get_word(const BIGNUM *a);
|
||||
|
||||
int BN_cmp(const BIGNUM *a, const BIGNUM *b);
|
||||
void BN_free(BIGNUM *a);
|
||||
int BN_is_bit_set(const BIGNUM *a, int n);
|
||||
int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
|
||||
int BN_lshift1(BIGNUM *r, const BIGNUM *a);
|
||||
int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,BN_CTX *ctx);
|
||||
|
||||
int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m,BN_CTX *ctx);
|
||||
int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||
int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont);
|
||||
int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||
int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1,
|
||||
const BIGNUM *a2, const BIGNUM *p2,const BIGNUM *m,
|
||||
BN_CTX *ctx,BN_MONT_CTX *m_ctx);
|
||||
int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m,BN_CTX *ctx);
|
||||
|
||||
int BN_mask_bits(BIGNUM *a,int n);
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
int BN_print_fp(FILE *fp, const BIGNUM *a);
|
||||
#endif
|
||||
#ifdef HEADER_BIO_H
|
||||
int BN_print(BIO *fp, const BIGNUM *a);
|
||||
#else
|
||||
int BN_print(void *fp, const BIGNUM *a);
|
||||
#endif
|
||||
int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);
|
||||
int BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
|
||||
int BN_rshift1(BIGNUM *r, const BIGNUM *a);
|
||||
void BN_clear(BIGNUM *a);
|
||||
BIGNUM *BN_dup(const BIGNUM *a);
|
||||
int BN_ucmp(const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_set_bit(BIGNUM *a, int n);
|
||||
int BN_clear_bit(BIGNUM *a, int n);
|
||||
char * BN_bn2hex(const BIGNUM *a);
|
||||
char * BN_bn2dec(const BIGNUM *a);
|
||||
int BN_hex2bn(BIGNUM **a, const char *str);
|
||||
int BN_dec2bn(BIGNUM **a, const char *str);
|
||||
int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx);
|
||||
int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */
|
||||
BIGNUM *BN_mod_inverse(BIGNUM *ret,
|
||||
const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
|
||||
BIGNUM *BN_mod_sqrt(BIGNUM *ret,
|
||||
const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
|
||||
|
||||
/* Deprecated versions */
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe,
|
||||
const BIGNUM *add, const BIGNUM *rem,
|
||||
void (*callback)(int,int,void *),void *cb_arg);
|
||||
int BN_is_prime(const BIGNUM *p,int nchecks,
|
||||
void (*callback)(int,int,void *),
|
||||
BN_CTX *ctx,void *cb_arg);
|
||||
int BN_is_prime_fasttest(const BIGNUM *p,int nchecks,
|
||||
void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg,
|
||||
int do_trial_division);
|
||||
#endif /* !defined(OPENSSL_NO_DEPRECATED) */
|
||||
|
||||
/* Newer versions */
|
||||
int BN_generate_prime_ex(BIGNUM *ret,int bits,int safe, const BIGNUM *add,
|
||||
const BIGNUM *rem, BN_GENCB *cb);
|
||||
int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb);
|
||||
int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx,
|
||||
int do_trial_division, BN_GENCB *cb);
|
||||
|
||||
BN_MONT_CTX *BN_MONT_CTX_new(void );
|
||||
void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
|
||||
int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,
|
||||
BN_MONT_CTX *mont, BN_CTX *ctx);
|
||||
#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\
|
||||
(r),(a),&((mont)->RR),(mont),(ctx))
|
||||
int BN_from_montgomery(BIGNUM *r,const BIGNUM *a,
|
||||
BN_MONT_CTX *mont, BN_CTX *ctx);
|
||||
void BN_MONT_CTX_free(BN_MONT_CTX *mont);
|
||||
int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *mod,BN_CTX *ctx);
|
||||
BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from);
|
||||
BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,
|
||||
const BIGNUM *mod, BN_CTX *ctx);
|
||||
|
||||
/* BN_BLINDING flags */
|
||||
#define BN_BLINDING_NO_UPDATE 0x00000001
|
||||
#define BN_BLINDING_NO_RECREATE 0x00000002
|
||||
|
||||
BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod);
|
||||
void BN_BLINDING_free(BN_BLINDING *b);
|
||||
int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx);
|
||||
int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
|
||||
int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
|
||||
int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);
|
||||
int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *);
|
||||
unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);
|
||||
void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);
|
||||
unsigned long BN_BLINDING_get_flags(const BN_BLINDING *);
|
||||
void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);
|
||||
BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
|
||||
const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
|
||||
int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx),
|
||||
BN_MONT_CTX *m_ctx);
|
||||
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
void BN_set_params(int mul,int high,int low,int mont);
|
||||
int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */
|
||||
#endif
|
||||
|
||||
void BN_RECP_CTX_init(BN_RECP_CTX *recp);
|
||||
BN_RECP_CTX *BN_RECP_CTX_new(void);
|
||||
void BN_RECP_CTX_free(BN_RECP_CTX *recp);
|
||||
int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx);
|
||||
int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
|
||||
BN_RECP_CTX *recp,BN_CTX *ctx);
|
||||
int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
|
||||
BN_RECP_CTX *recp, BN_CTX *ctx);
|
||||
|
||||
/* Functions for arithmetic over binary polynomials represented by BIGNUMs.
|
||||
*
|
||||
* The BIGNUM::neg property of BIGNUMs representing binary polynomials is
|
||||
* ignored.
|
||||
*
|
||||
* Note that input arguments are not const so that their bit arrays can
|
||||
* be expanded to the appropriate size if needed.
|
||||
*/
|
||||
|
||||
int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); /*r = a + b*/
|
||||
#define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b)
|
||||
int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p); /*r=a mod p*/
|
||||
int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *p, BN_CTX *ctx); /* r = (a * b) mod p */
|
||||
int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
BN_CTX *ctx); /* r = (a * a) mod p */
|
||||
int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p,
|
||||
BN_CTX *ctx); /* r = (1 / b) mod p */
|
||||
int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *p, BN_CTX *ctx); /* r = (a / b) mod p */
|
||||
int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *p, BN_CTX *ctx); /* r = (a ^ b) mod p */
|
||||
int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
BN_CTX *ctx); /* r = sqrt(a) mod p */
|
||||
int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
BN_CTX *ctx); /* r^2 + r = a mod p */
|
||||
#define BN_GF2m_cmp(a, b) BN_ucmp((a), (b))
|
||||
/* Some functions allow for representation of the irreducible polynomials
|
||||
* as an unsigned int[], say p. The irreducible f(t) is then of the form:
|
||||
* t^p[0] + t^p[1] + ... + t^p[k]
|
||||
* where m = p[0] > p[1] > ... > p[k] = 0.
|
||||
*/
|
||||
int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[]);
|
||||
/* r = a mod p */
|
||||
int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const unsigned int p[], BN_CTX *ctx); /* r = (a * b) mod p */
|
||||
int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[],
|
||||
BN_CTX *ctx); /* r = (a * a) mod p */
|
||||
int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const unsigned int p[],
|
||||
BN_CTX *ctx); /* r = (1 / b) mod p */
|
||||
int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const unsigned int p[], BN_CTX *ctx); /* r = (a / b) mod p */
|
||||
int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const unsigned int p[], BN_CTX *ctx); /* r = (a ^ b) mod p */
|
||||
int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,
|
||||
const unsigned int p[], BN_CTX *ctx); /* r = sqrt(a) mod p */
|
||||
int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,
|
||||
const unsigned int p[], BN_CTX *ctx); /* r^2 + r = a mod p */
|
||||
int BN_GF2m_poly2arr(const BIGNUM *a, unsigned int p[], int max);
|
||||
int BN_GF2m_arr2poly(const unsigned int p[], BIGNUM *a);
|
||||
|
||||
/* faster mod functions for the 'NIST primes'
|
||||
* 0 <= a < p^2 */
|
||||
int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
|
||||
const BIGNUM *BN_get0_nist_prime_192(void);
|
||||
const BIGNUM *BN_get0_nist_prime_224(void);
|
||||
const BIGNUM *BN_get0_nist_prime_256(void);
|
||||
const BIGNUM *BN_get0_nist_prime_384(void);
|
||||
const BIGNUM *BN_get0_nist_prime_521(void);
|
||||
|
||||
/* library internal functions */
|
||||
|
||||
#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\
|
||||
(a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2))
|
||||
#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))
|
||||
BIGNUM *bn_expand2(BIGNUM *a, int words);
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */
|
||||
#endif
|
||||
|
||||
/* Bignum consistency macros
|
||||
* There is one "API" macro, bn_fix_top(), for stripping leading zeroes from
|
||||
* bignum data after direct manipulations on the data. There is also an
|
||||
* "internal" macro, bn_check_top(), for verifying that there are no leading
|
||||
* zeroes. Unfortunately, some auditing is required due to the fact that
|
||||
* bn_fix_top() has become an overabused duct-tape because bignum data is
|
||||
* occasionally passed around in an inconsistent state. So the following
|
||||
* changes have been made to sort this out;
|
||||
* - bn_fix_top()s implementation has been moved to bn_correct_top()
|
||||
* - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and
|
||||
* bn_check_top() is as before.
|
||||
* - if BN_DEBUG *is* defined;
|
||||
* - bn_check_top() tries to pollute unused words even if the bignum 'top' is
|
||||
* consistent. (ed: only if BN_DEBUG_RAND is defined)
|
||||
* - bn_fix_top() maps to bn_check_top() rather than "fixing" anything.
|
||||
* The idea is to have debug builds flag up inconsistent bignums when they
|
||||
* occur. If that occurs in a bn_fix_top(), we examine the code in question; if
|
||||
* the use of bn_fix_top() was appropriate (ie. it follows directly after code
|
||||
* that manipulates the bignum) it is converted to bn_correct_top(), and if it
|
||||
* was not appropriate, we convert it permanently to bn_check_top() and track
|
||||
* down the cause of the bug. Eventually, no internal code should be using the
|
||||
* bn_fix_top() macro. External applications and libraries should try this with
|
||||
* their own code too, both in terms of building against the openssl headers
|
||||
* with BN_DEBUG defined *and* linking with a version of OpenSSL built with it
|
||||
* defined. This not only improves external code, it provides more test
|
||||
* coverage for openssl's own code.
|
||||
*/
|
||||
|
||||
#ifdef BN_DEBUG
|
||||
|
||||
/* We only need assert() when debugging */
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef BN_DEBUG_RAND
|
||||
/* To avoid "make update" cvs wars due to BN_DEBUG, use some tricks */
|
||||
#ifndef RAND_pseudo_bytes
|
||||
int RAND_pseudo_bytes(unsigned char *buf,int num);
|
||||
#define BN_DEBUG_TRIX
|
||||
#endif
|
||||
#define bn_pollute(a) \
|
||||
do { \
|
||||
const BIGNUM *_bnum1 = (a); \
|
||||
if(_bnum1->top < _bnum1->dmax) { \
|
||||
unsigned char _tmp_char; \
|
||||
/* We cast away const without the compiler knowing, any \
|
||||
* *genuinely* constant variables that aren't mutable \
|
||||
* wouldn't be constructed with top!=dmax. */ \
|
||||
BN_ULONG *_not_const; \
|
||||
memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \
|
||||
RAND_pseudo_bytes(&_tmp_char, 1); \
|
||||
memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \
|
||||
(_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \
|
||||
} \
|
||||
} while(0)
|
||||
#ifdef BN_DEBUG_TRIX
|
||||
#undef RAND_pseudo_bytes
|
||||
#endif
|
||||
#else
|
||||
#define bn_pollute(a)
|
||||
#endif
|
||||
#define bn_check_top(a) \
|
||||
do { \
|
||||
const BIGNUM *_bnum2 = (a); \
|
||||
if (_bnum2 != NULL) { \
|
||||
assert((_bnum2->top == 0) || \
|
||||
(_bnum2->d[_bnum2->top - 1] != 0)); \
|
||||
bn_pollute(_bnum2); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define bn_fix_top(a) bn_check_top(a)
|
||||
|
||||
#else /* !BN_DEBUG */
|
||||
|
||||
#define bn_pollute(a)
|
||||
#define bn_check_top(a)
|
||||
#define bn_fix_top(a) bn_correct_top(a)
|
||||
|
||||
#endif
|
||||
|
||||
#define bn_correct_top(a) \
|
||||
{ \
|
||||
BN_ULONG *ftl; \
|
||||
if ((a)->top > 0) \
|
||||
{ \
|
||||
for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \
|
||||
if (*(ftl--)) break; \
|
||||
} \
|
||||
bn_pollute(a); \
|
||||
}
|
||||
|
||||
BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
|
||||
BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
|
||||
void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);
|
||||
BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
|
||||
BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num);
|
||||
BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num);
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
/* Primes from RFC 2409 */
|
||||
BIGNUM *get_rfc2409_prime_768(BIGNUM *bn);
|
||||
BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn);
|
||||
|
||||
/* Primes from RFC 3526 */
|
||||
BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_2048(BIGNUM *bn);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
BIGNUM *get_rfc3526_prime_3072(BIGNUM *bn);
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom);
|
||||
|
||||
/* 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_BN_strings(void);
|
||||
|
||||
/* Error codes for the BN functions. */
|
||||
|
||||
/* Function codes. */
|
||||
#define BN_F_BNRAND 127
|
||||
#define BN_F_BN_BLINDING_CONVERT_EX 100
|
||||
#define BN_F_BN_BLINDING_CREATE_PARAM 128
|
||||
#define BN_F_BN_BLINDING_INVERT_EX 101
|
||||
#define BN_F_BN_BLINDING_NEW 102
|
||||
#define BN_F_BN_BLINDING_UPDATE 103
|
||||
#define BN_F_BN_BN2DEC 104
|
||||
#define BN_F_BN_BN2HEX 105
|
||||
#define BN_F_BN_CTX_GET 116
|
||||
#define BN_F_BN_CTX_NEW 106
|
||||
#define BN_F_BN_CTX_START 129
|
||||
#define BN_F_BN_DIV 107
|
||||
#define BN_F_BN_DIV_RECP 130
|
||||
#define BN_F_BN_EXP 123
|
||||
#define BN_F_BN_EXPAND2 108
|
||||
#define BN_F_BN_EXPAND_INTERNAL 120
|
||||
#define BN_F_BN_GF2M_MOD 131
|
||||
#define BN_F_BN_GF2M_MOD_EXP 132
|
||||
#define BN_F_BN_GF2M_MOD_MUL 133
|
||||
#define BN_F_BN_GF2M_MOD_SOLVE_QUAD 134
|
||||
#define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 135
|
||||
#define BN_F_BN_GF2M_MOD_SQR 136
|
||||
#define BN_F_BN_GF2M_MOD_SQRT 137
|
||||
#define BN_F_BN_MOD_EXP2_MONT 118
|
||||
#define BN_F_BN_MOD_EXP_MONT 109
|
||||
#define BN_F_BN_MOD_EXP_MONT_CONSTTIME 124
|
||||
#define BN_F_BN_MOD_EXP_MONT_WORD 117
|
||||
#define BN_F_BN_MOD_EXP_RECP 125
|
||||
#define BN_F_BN_MOD_EXP_SIMPLE 126
|
||||
#define BN_F_BN_MOD_INVERSE 110
|
||||
#define BN_F_BN_MOD_LSHIFT_QUICK 119
|
||||
#define BN_F_BN_MOD_MUL_RECIPROCAL 111
|
||||
#define BN_F_BN_MOD_SQRT 121
|
||||
#define BN_F_BN_MPI2BN 112
|
||||
#define BN_F_BN_NEW 113
|
||||
#define BN_F_BN_RAND 114
|
||||
#define BN_F_BN_RAND_RANGE 122
|
||||
#define BN_F_BN_USUB 115
|
||||
|
||||
/* Reason codes. */
|
||||
#define BN_R_ARG2_LT_ARG3 100
|
||||
#define BN_R_BAD_RECIPROCAL 101
|
||||
#define BN_R_BIGNUM_TOO_LONG 114
|
||||
#define BN_R_CALLED_WITH_EVEN_MODULUS 102
|
||||
#define BN_R_DIV_BY_ZERO 103
|
||||
#define BN_R_ENCODING_ERROR 104
|
||||
#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105
|
||||
#define BN_R_INPUT_NOT_REDUCED 110
|
||||
#define BN_R_INVALID_LENGTH 106
|
||||
#define BN_R_INVALID_RANGE 115
|
||||
#define BN_R_NOT_A_SQUARE 111
|
||||
#define BN_R_NOT_INITIALIZED 107
|
||||
#define BN_R_NO_INVERSE 108
|
||||
#define BN_R_NO_SOLUTION 116
|
||||
#define BN_R_P_IS_NOT_PRIME 112
|
||||
#define BN_R_TOO_MANY_ITERATIONS 113
|
||||
#define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
489
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/bn_lcl.h
Executable file
489
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/bn_lcl.h
Executable file
@ -0,0 +1,489 @@
|
||||
/* crypto/bn/bn_lcl.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2000 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).
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BN_LCL_H
|
||||
#define HEADER_BN_LCL_H
|
||||
|
||||
#include <openssl/bn.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* BN_window_bits_for_exponent_size -- macro for sliding window mod_exp functions
|
||||
*
|
||||
*
|
||||
* For window size 'w' (w >= 2) and a random 'b' bits exponent,
|
||||
* the number of multiplications is a constant plus on average
|
||||
*
|
||||
* 2^(w-1) + (b-w)/(w+1);
|
||||
*
|
||||
* here 2^(w-1) is for precomputing the table (we actually need
|
||||
* entries only for windows that have the lowest bit set), and
|
||||
* (b-w)/(w+1) is an approximation for the expected number of
|
||||
* w-bit windows, not counting the first one.
|
||||
*
|
||||
* Thus we should use
|
||||
*
|
||||
* w >= 6 if b > 671
|
||||
* w = 5 if 671 > b > 239
|
||||
* w = 4 if 239 > b > 79
|
||||
* w = 3 if 79 > b > 23
|
||||
* w <= 2 if 23 > b
|
||||
*
|
||||
* (with draws in between). Very small exponents are often selected
|
||||
* with low Hamming weight, so we use w = 1 for b <= 23.
|
||||
*/
|
||||
#if 1
|
||||
#define BN_window_bits_for_exponent_size(b) \
|
||||
((b) > 671 ? 6 : \
|
||||
(b) > 239 ? 5 : \
|
||||
(b) > 79 ? 4 : \
|
||||
(b) > 23 ? 3 : 1)
|
||||
#else
|
||||
/* Old SSLeay/OpenSSL table.
|
||||
* Maximum window size was 5, so this table differs for b==1024;
|
||||
* but it coincides for other interesting values (b==160, b==512).
|
||||
*/
|
||||
#define BN_window_bits_for_exponent_size(b) \
|
||||
((b) > 255 ? 5 : \
|
||||
(b) > 127 ? 4 : \
|
||||
(b) > 17 ? 3 : 1)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* BN_mod_exp_mont_conttime is based on the assumption that the
|
||||
* L1 data cache line width of the target processor is at least
|
||||
* the following value.
|
||||
*/
|
||||
#define MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH ( 64 )
|
||||
#define MOD_EXP_CTIME_MIN_CACHE_LINE_MASK (MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH - 1)
|
||||
|
||||
/* Window sizes optimized for fixed window size modular exponentiation
|
||||
* algorithm (BN_mod_exp_mont_consttime).
|
||||
*
|
||||
* To achieve the security goals of BN_mode_exp_mont_consttime, the
|
||||
* maximum size of the window must not exceed
|
||||
* log_2(MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH).
|
||||
*
|
||||
* Window size thresholds are defined for cache line sizes of 32 and 64,
|
||||
* cache line sizes where log_2(32)=5 and log_2(64)=6 respectively. A
|
||||
* window size of 7 should only be used on processors that have a 128
|
||||
* byte or greater cache line size.
|
||||
*/
|
||||
#if MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 64
|
||||
|
||||
# define BN_window_bits_for_ctime_exponent_size(b) \
|
||||
((b) > 937 ? 6 : \
|
||||
(b) > 306 ? 5 : \
|
||||
(b) > 89 ? 4 : \
|
||||
(b) > 22 ? 3 : 1)
|
||||
# define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (6)
|
||||
|
||||
#elif MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 32
|
||||
|
||||
# define BN_window_bits_for_ctime_exponent_size(b) \
|
||||
((b) > 306 ? 5 : \
|
||||
(b) > 89 ? 4 : \
|
||||
(b) > 22 ? 3 : 1)
|
||||
# define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (5)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* Pentium pro 16,16,16,32,64 */
|
||||
/* Alpha 16,16,16,16.64 */
|
||||
#define BN_MULL_SIZE_NORMAL (16) /* 32 */
|
||||
#define BN_MUL_RECURSIVE_SIZE_NORMAL (16) /* 32 less than */
|
||||
#define BN_SQR_RECURSIVE_SIZE_NORMAL (16) /* 32 */
|
||||
#define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32) /* 32 */
|
||||
#define BN_MONT_CTX_SET_SIZE_WORD (64) /* 32 */
|
||||
|
||||
#if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC)
|
||||
/*
|
||||
* BN_UMULT_HIGH section.
|
||||
*
|
||||
* No, I'm not trying to overwhelm you when stating that the
|
||||
* product of N-bit numbers is 2*N bits wide:-) No, I don't expect
|
||||
* you to be impressed when I say that if the compiler doesn't
|
||||
* support 2*N integer type, then you have to replace every N*N
|
||||
* multiplication with 4 (N/2)*(N/2) accompanied by some shifts
|
||||
* and additions which unavoidably results in severe performance
|
||||
* penalties. Of course provided that the hardware is capable of
|
||||
* producing 2*N result... That's when you normally start
|
||||
* considering assembler implementation. However! It should be
|
||||
* pointed out that some CPUs (most notably Alpha, PowerPC and
|
||||
* upcoming IA-64 family:-) provide *separate* instruction
|
||||
* calculating the upper half of the product placing the result
|
||||
* into a general purpose register. Now *if* the compiler supports
|
||||
* inline assembler, then it's not impossible to implement the
|
||||
* "bignum" routines (and have the compiler optimize 'em)
|
||||
* exhibiting "native" performance in C. That's what BN_UMULT_HIGH
|
||||
* macro is about:-)
|
||||
*
|
||||
* <appro@fy.chalmers.se>
|
||||
*/
|
||||
# if defined(__alpha) && (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT))
|
||||
# if defined(__DECC)
|
||||
# include <c_asm.h>
|
||||
# define BN_UMULT_HIGH(a,b) (BN_ULONG)asm("umulh %a0,%a1,%v0",(a),(b))
|
||||
# elif defined(__GNUC__)
|
||||
# define BN_UMULT_HIGH(a,b) ({ \
|
||||
register BN_ULONG ret; \
|
||||
asm ("umulh %1,%2,%0" \
|
||||
: "=r"(ret) \
|
||||
: "r"(a), "r"(b)); \
|
||||
ret; })
|
||||
# endif /* compiler */
|
||||
# elif defined(_ARCH_PPC) && defined(__64BIT__) && defined(SIXTY_FOUR_BIT_LONG)
|
||||
# if defined(__GNUC__)
|
||||
# define BN_UMULT_HIGH(a,b) ({ \
|
||||
register BN_ULONG ret; \
|
||||
asm ("mulhdu %0,%1,%2" \
|
||||
: "=r"(ret) \
|
||||
: "r"(a), "r"(b)); \
|
||||
ret; })
|
||||
# endif /* compiler */
|
||||
# elif defined(__x86_64) && defined(SIXTY_FOUR_BIT_LONG)
|
||||
# if defined(__GNUC__)
|
||||
# define BN_UMULT_HIGH(a,b) ({ \
|
||||
register BN_ULONG ret,discard; \
|
||||
asm ("mulq %3" \
|
||||
: "=a"(discard),"=d"(ret) \
|
||||
: "a"(a), "g"(b) \
|
||||
: "cc"); \
|
||||
ret; })
|
||||
# define BN_UMULT_LOHI(low,high,a,b) \
|
||||
asm ("mulq %3" \
|
||||
: "=a"(low),"=d"(high) \
|
||||
: "a"(a),"g"(b) \
|
||||
: "cc");
|
||||
# endif
|
||||
# elif (defined(_M_AMD64) || defined(_M_X64)) && defined(SIXTY_FOUR_BIT)
|
||||
# if defined(_MSC_VER) && _MSC_VER>=1400
|
||||
unsigned __int64 __umulh (unsigned __int64 a,unsigned __int64 b);
|
||||
unsigned __int64 _umul128 (unsigned __int64 a,unsigned __int64 b,
|
||||
unsigned __int64 *h);
|
||||
# pragma intrinsic(__umulh,_umul128)
|
||||
# define BN_UMULT_HIGH(a,b) __umulh((a),(b))
|
||||
# define BN_UMULT_LOHI(low,high,a,b) ((low)=_umul128((a),(b),&(high)))
|
||||
# endif
|
||||
# endif /* cpu */
|
||||
#endif /* OPENSSL_NO_ASM */
|
||||
|
||||
/*************************************************************
|
||||
* Using the long long type
|
||||
*/
|
||||
#define Lw(t) (((BN_ULONG)(t))&BN_MASK2)
|
||||
#define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2)
|
||||
|
||||
#ifdef BN_DEBUG_RAND
|
||||
#define bn_clear_top2max(a) \
|
||||
{ \
|
||||
int ind = (a)->dmax - (a)->top; \
|
||||
BN_ULONG *ftl = &(a)->d[(a)->top-1]; \
|
||||
for (; ind != 0; ind--) \
|
||||
*(++ftl) = 0x0; \
|
||||
}
|
||||
#else
|
||||
#define bn_clear_top2max(a)
|
||||
#endif
|
||||
|
||||
#ifdef BN_LLONG
|
||||
#define mul_add(r,a,w,c) { \
|
||||
BN_ULLONG t; \
|
||||
t=(BN_ULLONG)w * (a) + (r) + (c); \
|
||||
(r)= Lw(t); \
|
||||
(c)= Hw(t); \
|
||||
}
|
||||
|
||||
#define mul(r,a,w,c) { \
|
||||
BN_ULLONG t; \
|
||||
t=(BN_ULLONG)w * (a) + (c); \
|
||||
(r)= Lw(t); \
|
||||
(c)= Hw(t); \
|
||||
}
|
||||
|
||||
#define sqr(r0,r1,a) { \
|
||||
BN_ULLONG t; \
|
||||
t=(BN_ULLONG)(a)*(a); \
|
||||
(r0)=Lw(t); \
|
||||
(r1)=Hw(t); \
|
||||
}
|
||||
|
||||
#elif defined(BN_UMULT_LOHI)
|
||||
#define mul_add(r,a,w,c) { \
|
||||
BN_ULONG high,low,ret,tmp=(a); \
|
||||
ret = (r); \
|
||||
BN_UMULT_LOHI(low,high,w,tmp); \
|
||||
ret += (c); \
|
||||
(c) = (ret<(c))?1:0; \
|
||||
(c) += high; \
|
||||
ret += low; \
|
||||
(c) += (ret<low)?1:0; \
|
||||
(r) = ret; \
|
||||
}
|
||||
|
||||
#define mul(r,a,w,c) { \
|
||||
BN_ULONG high,low,ret,ta=(a); \
|
||||
BN_UMULT_LOHI(low,high,w,ta); \
|
||||
ret = low + (c); \
|
||||
(c) = high; \
|
||||
(c) += (ret<low)?1:0; \
|
||||
(r) = ret; \
|
||||
}
|
||||
|
||||
#define sqr(r0,r1,a) { \
|
||||
BN_ULONG tmp=(a); \
|
||||
BN_UMULT_LOHI(r0,r1,tmp,tmp); \
|
||||
}
|
||||
|
||||
#elif defined(BN_UMULT_HIGH)
|
||||
#define mul_add(r,a,w,c) { \
|
||||
BN_ULONG high,low,ret,tmp=(a); \
|
||||
ret = (r); \
|
||||
high= BN_UMULT_HIGH(w,tmp); \
|
||||
ret += (c); \
|
||||
low = (w) * tmp; \
|
||||
(c) = (ret<(c))?1:0; \
|
||||
(c) += high; \
|
||||
ret += low; \
|
||||
(c) += (ret<low)?1:0; \
|
||||
(r) = ret; \
|
||||
}
|
||||
|
||||
#define mul(r,a,w,c) { \
|
||||
BN_ULONG high,low,ret,ta=(a); \
|
||||
low = (w) * ta; \
|
||||
high= BN_UMULT_HIGH(w,ta); \
|
||||
ret = low + (c); \
|
||||
(c) = high; \
|
||||
(c) += (ret<low)?1:0; \
|
||||
(r) = ret; \
|
||||
}
|
||||
|
||||
#define sqr(r0,r1,a) { \
|
||||
BN_ULONG tmp=(a); \
|
||||
(r0) = tmp * tmp; \
|
||||
(r1) = BN_UMULT_HIGH(tmp,tmp); \
|
||||
}
|
||||
|
||||
#else
|
||||
/*************************************************************
|
||||
* No long long type
|
||||
*/
|
||||
|
||||
#define LBITS(a) ((a)&BN_MASK2l)
|
||||
#define HBITS(a) (((a)>>BN_BITS4)&BN_MASK2l)
|
||||
#define L2HBITS(a) (((a)<<BN_BITS4)&BN_MASK2)
|
||||
|
||||
#define LLBITS(a) ((a)&BN_MASKl)
|
||||
#define LHBITS(a) (((a)>>BN_BITS2)&BN_MASKl)
|
||||
#define LL2HBITS(a) ((BN_ULLONG)((a)&BN_MASKl)<<BN_BITS2)
|
||||
|
||||
#define mul64(l,h,bl,bh) \
|
||||
{ \
|
||||
BN_ULONG m,m1,lt,ht; \
|
||||
\
|
||||
lt=l; \
|
||||
ht=h; \
|
||||
m =(bh)*(lt); \
|
||||
lt=(bl)*(lt); \
|
||||
m1=(bl)*(ht); \
|
||||
ht =(bh)*(ht); \
|
||||
m=(m+m1)&BN_MASK2; if (m < m1) ht+=L2HBITS((BN_ULONG)1); \
|
||||
ht+=HBITS(m); \
|
||||
m1=L2HBITS(m); \
|
||||
lt=(lt+m1)&BN_MASK2; if (lt < m1) ht++; \
|
||||
(l)=lt; \
|
||||
(h)=ht; \
|
||||
}
|
||||
|
||||
#define sqr64(lo,ho,in) \
|
||||
{ \
|
||||
BN_ULONG l,h,m; \
|
||||
\
|
||||
h=(in); \
|
||||
l=LBITS(h); \
|
||||
h=HBITS(h); \
|
||||
m =(l)*(h); \
|
||||
l*=l; \
|
||||
h*=h; \
|
||||
h+=(m&BN_MASK2h1)>>(BN_BITS4-1); \
|
||||
m =(m&BN_MASK2l)<<(BN_BITS4+1); \
|
||||
l=(l+m)&BN_MASK2; if (l < m) h++; \
|
||||
(lo)=l; \
|
||||
(ho)=h; \
|
||||
}
|
||||
|
||||
#define mul_add(r,a,bl,bh,c) { \
|
||||
BN_ULONG l,h; \
|
||||
\
|
||||
h= (a); \
|
||||
l=LBITS(h); \
|
||||
h=HBITS(h); \
|
||||
mul64(l,h,(bl),(bh)); \
|
||||
\
|
||||
/* non-multiply part */ \
|
||||
l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
|
||||
(c)=(r); \
|
||||
l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
|
||||
(c)=h&BN_MASK2; \
|
||||
(r)=l; \
|
||||
}
|
||||
|
||||
#define mul(r,a,bl,bh,c) { \
|
||||
BN_ULONG l,h; \
|
||||
\
|
||||
h= (a); \
|
||||
l=LBITS(h); \
|
||||
h=HBITS(h); \
|
||||
mul64(l,h,(bl),(bh)); \
|
||||
\
|
||||
/* non-multiply part */ \
|
||||
l+=(c); if ((l&BN_MASK2) < (c)) h++; \
|
||||
(c)=h&BN_MASK2; \
|
||||
(r)=l&BN_MASK2; \
|
||||
}
|
||||
#endif /* !BN_LLONG */
|
||||
|
||||
void bn_mul_normal(BN_ULONG *r,BN_ULONG *a,int na,BN_ULONG *b,int nb);
|
||||
void bn_mul_comba8(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
|
||||
void bn_mul_comba4(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
|
||||
void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp);
|
||||
void bn_sqr_comba8(BN_ULONG *r,const BN_ULONG *a);
|
||||
void bn_sqr_comba4(BN_ULONG *r,const BN_ULONG *a);
|
||||
int bn_cmp_words(const BN_ULONG *a,const BN_ULONG *b,int n);
|
||||
int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b,
|
||||
int cl, int dl);
|
||||
void bn_mul_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,
|
||||
int dna,int dnb,BN_ULONG *t);
|
||||
void bn_mul_part_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,
|
||||
int n,int tna,int tnb,BN_ULONG *t);
|
||||
void bn_sqr_recursive(BN_ULONG *r,const BN_ULONG *a, int n2, BN_ULONG *t);
|
||||
void bn_mul_low_normal(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b, int n);
|
||||
void bn_mul_low_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,
|
||||
BN_ULONG *t);
|
||||
void bn_mul_high(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,BN_ULONG *l,int n2,
|
||||
BN_ULONG *t);
|
||||
BN_ULONG bn_add_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
|
||||
int cl, int dl);
|
||||
BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
|
||||
int cl, int dl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
325
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/bn_prime.h
Executable file
325
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/bn_prime.h
Executable file
@ -0,0 +1,325 @@
|
||||
/* Auto generated by bn_prime.pl */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef EIGHT_BIT
|
||||
#define NUMPRIMES 2048
|
||||
#else
|
||||
#define NUMPRIMES 54
|
||||
#endif
|
||||
static const unsigned int primes[NUMPRIMES]=
|
||||
{
|
||||
2, 3, 5, 7, 11, 13, 17, 19,
|
||||
23, 29, 31, 37, 41, 43, 47, 53,
|
||||
59, 61, 67, 71, 73, 79, 83, 89,
|
||||
97, 101, 103, 107, 109, 113, 127, 131,
|
||||
137, 139, 149, 151, 157, 163, 167, 173,
|
||||
179, 181, 191, 193, 197, 199, 211, 223,
|
||||
227, 229, 233, 239, 241, 251,
|
||||
#ifndef EIGHT_BIT
|
||||
257, 263,
|
||||
269, 271, 277, 281, 283, 293, 307, 311,
|
||||
313, 317, 331, 337, 347, 349, 353, 359,
|
||||
367, 373, 379, 383, 389, 397, 401, 409,
|
||||
419, 421, 431, 433, 439, 443, 449, 457,
|
||||
461, 463, 467, 479, 487, 491, 499, 503,
|
||||
509, 521, 523, 541, 547, 557, 563, 569,
|
||||
571, 577, 587, 593, 599, 601, 607, 613,
|
||||
617, 619, 631, 641, 643, 647, 653, 659,
|
||||
661, 673, 677, 683, 691, 701, 709, 719,
|
||||
727, 733, 739, 743, 751, 757, 761, 769,
|
||||
773, 787, 797, 809, 811, 821, 823, 827,
|
||||
829, 839, 853, 857, 859, 863, 877, 881,
|
||||
883, 887, 907, 911, 919, 929, 937, 941,
|
||||
947, 953, 967, 971, 977, 983, 991, 997,
|
||||
1009,1013,1019,1021,1031,1033,1039,1049,
|
||||
1051,1061,1063,1069,1087,1091,1093,1097,
|
||||
1103,1109,1117,1123,1129,1151,1153,1163,
|
||||
1171,1181,1187,1193,1201,1213,1217,1223,
|
||||
1229,1231,1237,1249,1259,1277,1279,1283,
|
||||
1289,1291,1297,1301,1303,1307,1319,1321,
|
||||
1327,1361,1367,1373,1381,1399,1409,1423,
|
||||
1427,1429,1433,1439,1447,1451,1453,1459,
|
||||
1471,1481,1483,1487,1489,1493,1499,1511,
|
||||
1523,1531,1543,1549,1553,1559,1567,1571,
|
||||
1579,1583,1597,1601,1607,1609,1613,1619,
|
||||
1621,1627,1637,1657,1663,1667,1669,1693,
|
||||
1697,1699,1709,1721,1723,1733,1741,1747,
|
||||
1753,1759,1777,1783,1787,1789,1801,1811,
|
||||
1823,1831,1847,1861,1867,1871,1873,1877,
|
||||
1879,1889,1901,1907,1913,1931,1933,1949,
|
||||
1951,1973,1979,1987,1993,1997,1999,2003,
|
||||
2011,2017,2027,2029,2039,2053,2063,2069,
|
||||
2081,2083,2087,2089,2099,2111,2113,2129,
|
||||
2131,2137,2141,2143,2153,2161,2179,2203,
|
||||
2207,2213,2221,2237,2239,2243,2251,2267,
|
||||
2269,2273,2281,2287,2293,2297,2309,2311,
|
||||
2333,2339,2341,2347,2351,2357,2371,2377,
|
||||
2381,2383,2389,2393,2399,2411,2417,2423,
|
||||
2437,2441,2447,2459,2467,2473,2477,2503,
|
||||
2521,2531,2539,2543,2549,2551,2557,2579,
|
||||
2591,2593,2609,2617,2621,2633,2647,2657,
|
||||
2659,2663,2671,2677,2683,2687,2689,2693,
|
||||
2699,2707,2711,2713,2719,2729,2731,2741,
|
||||
2749,2753,2767,2777,2789,2791,2797,2801,
|
||||
2803,2819,2833,2837,2843,2851,2857,2861,
|
||||
2879,2887,2897,2903,2909,2917,2927,2939,
|
||||
2953,2957,2963,2969,2971,2999,3001,3011,
|
||||
3019,3023,3037,3041,3049,3061,3067,3079,
|
||||
3083,3089,3109,3119,3121,3137,3163,3167,
|
||||
3169,3181,3187,3191,3203,3209,3217,3221,
|
||||
3229,3251,3253,3257,3259,3271,3299,3301,
|
||||
3307,3313,3319,3323,3329,3331,3343,3347,
|
||||
3359,3361,3371,3373,3389,3391,3407,3413,
|
||||
3433,3449,3457,3461,3463,3467,3469,3491,
|
||||
3499,3511,3517,3527,3529,3533,3539,3541,
|
||||
3547,3557,3559,3571,3581,3583,3593,3607,
|
||||
3613,3617,3623,3631,3637,3643,3659,3671,
|
||||
3673,3677,3691,3697,3701,3709,3719,3727,
|
||||
3733,3739,3761,3767,3769,3779,3793,3797,
|
||||
3803,3821,3823,3833,3847,3851,3853,3863,
|
||||
3877,3881,3889,3907,3911,3917,3919,3923,
|
||||
3929,3931,3943,3947,3967,3989,4001,4003,
|
||||
4007,4013,4019,4021,4027,4049,4051,4057,
|
||||
4073,4079,4091,4093,4099,4111,4127,4129,
|
||||
4133,4139,4153,4157,4159,4177,4201,4211,
|
||||
4217,4219,4229,4231,4241,4243,4253,4259,
|
||||
4261,4271,4273,4283,4289,4297,4327,4337,
|
||||
4339,4349,4357,4363,4373,4391,4397,4409,
|
||||
4421,4423,4441,4447,4451,4457,4463,4481,
|
||||
4483,4493,4507,4513,4517,4519,4523,4547,
|
||||
4549,4561,4567,4583,4591,4597,4603,4621,
|
||||
4637,4639,4643,4649,4651,4657,4663,4673,
|
||||
4679,4691,4703,4721,4723,4729,4733,4751,
|
||||
4759,4783,4787,4789,4793,4799,4801,4813,
|
||||
4817,4831,4861,4871,4877,4889,4903,4909,
|
||||
4919,4931,4933,4937,4943,4951,4957,4967,
|
||||
4969,4973,4987,4993,4999,5003,5009,5011,
|
||||
5021,5023,5039,5051,5059,5077,5081,5087,
|
||||
5099,5101,5107,5113,5119,5147,5153,5167,
|
||||
5171,5179,5189,5197,5209,5227,5231,5233,
|
||||
5237,5261,5273,5279,5281,5297,5303,5309,
|
||||
5323,5333,5347,5351,5381,5387,5393,5399,
|
||||
5407,5413,5417,5419,5431,5437,5441,5443,
|
||||
5449,5471,5477,5479,5483,5501,5503,5507,
|
||||
5519,5521,5527,5531,5557,5563,5569,5573,
|
||||
5581,5591,5623,5639,5641,5647,5651,5653,
|
||||
5657,5659,5669,5683,5689,5693,5701,5711,
|
||||
5717,5737,5741,5743,5749,5779,5783,5791,
|
||||
5801,5807,5813,5821,5827,5839,5843,5849,
|
||||
5851,5857,5861,5867,5869,5879,5881,5897,
|
||||
5903,5923,5927,5939,5953,5981,5987,6007,
|
||||
6011,6029,6037,6043,6047,6053,6067,6073,
|
||||
6079,6089,6091,6101,6113,6121,6131,6133,
|
||||
6143,6151,6163,6173,6197,6199,6203,6211,
|
||||
6217,6221,6229,6247,6257,6263,6269,6271,
|
||||
6277,6287,6299,6301,6311,6317,6323,6329,
|
||||
6337,6343,6353,6359,6361,6367,6373,6379,
|
||||
6389,6397,6421,6427,6449,6451,6469,6473,
|
||||
6481,6491,6521,6529,6547,6551,6553,6563,
|
||||
6569,6571,6577,6581,6599,6607,6619,6637,
|
||||
6653,6659,6661,6673,6679,6689,6691,6701,
|
||||
6703,6709,6719,6733,6737,6761,6763,6779,
|
||||
6781,6791,6793,6803,6823,6827,6829,6833,
|
||||
6841,6857,6863,6869,6871,6883,6899,6907,
|
||||
6911,6917,6947,6949,6959,6961,6967,6971,
|
||||
6977,6983,6991,6997,7001,7013,7019,7027,
|
||||
7039,7043,7057,7069,7079,7103,7109,7121,
|
||||
7127,7129,7151,7159,7177,7187,7193,7207,
|
||||
7211,7213,7219,7229,7237,7243,7247,7253,
|
||||
7283,7297,7307,7309,7321,7331,7333,7349,
|
||||
7351,7369,7393,7411,7417,7433,7451,7457,
|
||||
7459,7477,7481,7487,7489,7499,7507,7517,
|
||||
7523,7529,7537,7541,7547,7549,7559,7561,
|
||||
7573,7577,7583,7589,7591,7603,7607,7621,
|
||||
7639,7643,7649,7669,7673,7681,7687,7691,
|
||||
7699,7703,7717,7723,7727,7741,7753,7757,
|
||||
7759,7789,7793,7817,7823,7829,7841,7853,
|
||||
7867,7873,7877,7879,7883,7901,7907,7919,
|
||||
7927,7933,7937,7949,7951,7963,7993,8009,
|
||||
8011,8017,8039,8053,8059,8069,8081,8087,
|
||||
8089,8093,8101,8111,8117,8123,8147,8161,
|
||||
8167,8171,8179,8191,8209,8219,8221,8231,
|
||||
8233,8237,8243,8263,8269,8273,8287,8291,
|
||||
8293,8297,8311,8317,8329,8353,8363,8369,
|
||||
8377,8387,8389,8419,8423,8429,8431,8443,
|
||||
8447,8461,8467,8501,8513,8521,8527,8537,
|
||||
8539,8543,8563,8573,8581,8597,8599,8609,
|
||||
8623,8627,8629,8641,8647,8663,8669,8677,
|
||||
8681,8689,8693,8699,8707,8713,8719,8731,
|
||||
8737,8741,8747,8753,8761,8779,8783,8803,
|
||||
8807,8819,8821,8831,8837,8839,8849,8861,
|
||||
8863,8867,8887,8893,8923,8929,8933,8941,
|
||||
8951,8963,8969,8971,8999,9001,9007,9011,
|
||||
9013,9029,9041,9043,9049,9059,9067,9091,
|
||||
9103,9109,9127,9133,9137,9151,9157,9161,
|
||||
9173,9181,9187,9199,9203,9209,9221,9227,
|
||||
9239,9241,9257,9277,9281,9283,9293,9311,
|
||||
9319,9323,9337,9341,9343,9349,9371,9377,
|
||||
9391,9397,9403,9413,9419,9421,9431,9433,
|
||||
9437,9439,9461,9463,9467,9473,9479,9491,
|
||||
9497,9511,9521,9533,9539,9547,9551,9587,
|
||||
9601,9613,9619,9623,9629,9631,9643,9649,
|
||||
9661,9677,9679,9689,9697,9719,9721,9733,
|
||||
9739,9743,9749,9767,9769,9781,9787,9791,
|
||||
9803,9811,9817,9829,9833,9839,9851,9857,
|
||||
9859,9871,9883,9887,9901,9907,9923,9929,
|
||||
9931,9941,9949,9967,9973,10007,10009,10037,
|
||||
10039,10061,10067,10069,10079,10091,10093,10099,
|
||||
10103,10111,10133,10139,10141,10151,10159,10163,
|
||||
10169,10177,10181,10193,10211,10223,10243,10247,
|
||||
10253,10259,10267,10271,10273,10289,10301,10303,
|
||||
10313,10321,10331,10333,10337,10343,10357,10369,
|
||||
10391,10399,10427,10429,10433,10453,10457,10459,
|
||||
10463,10477,10487,10499,10501,10513,10529,10531,
|
||||
10559,10567,10589,10597,10601,10607,10613,10627,
|
||||
10631,10639,10651,10657,10663,10667,10687,10691,
|
||||
10709,10711,10723,10729,10733,10739,10753,10771,
|
||||
10781,10789,10799,10831,10837,10847,10853,10859,
|
||||
10861,10867,10883,10889,10891,10903,10909,10937,
|
||||
10939,10949,10957,10973,10979,10987,10993,11003,
|
||||
11027,11047,11057,11059,11069,11071,11083,11087,
|
||||
11093,11113,11117,11119,11131,11149,11159,11161,
|
||||
11171,11173,11177,11197,11213,11239,11243,11251,
|
||||
11257,11261,11273,11279,11287,11299,11311,11317,
|
||||
11321,11329,11351,11353,11369,11383,11393,11399,
|
||||
11411,11423,11437,11443,11447,11467,11471,11483,
|
||||
11489,11491,11497,11503,11519,11527,11549,11551,
|
||||
11579,11587,11593,11597,11617,11621,11633,11657,
|
||||
11677,11681,11689,11699,11701,11717,11719,11731,
|
||||
11743,11777,11779,11783,11789,11801,11807,11813,
|
||||
11821,11827,11831,11833,11839,11863,11867,11887,
|
||||
11897,11903,11909,11923,11927,11933,11939,11941,
|
||||
11953,11959,11969,11971,11981,11987,12007,12011,
|
||||
12037,12041,12043,12049,12071,12073,12097,12101,
|
||||
12107,12109,12113,12119,12143,12149,12157,12161,
|
||||
12163,12197,12203,12211,12227,12239,12241,12251,
|
||||
12253,12263,12269,12277,12281,12289,12301,12323,
|
||||
12329,12343,12347,12373,12377,12379,12391,12401,
|
||||
12409,12413,12421,12433,12437,12451,12457,12473,
|
||||
12479,12487,12491,12497,12503,12511,12517,12527,
|
||||
12539,12541,12547,12553,12569,12577,12583,12589,
|
||||
12601,12611,12613,12619,12637,12641,12647,12653,
|
||||
12659,12671,12689,12697,12703,12713,12721,12739,
|
||||
12743,12757,12763,12781,12791,12799,12809,12821,
|
||||
12823,12829,12841,12853,12889,12893,12899,12907,
|
||||
12911,12917,12919,12923,12941,12953,12959,12967,
|
||||
12973,12979,12983,13001,13003,13007,13009,13033,
|
||||
13037,13043,13049,13063,13093,13099,13103,13109,
|
||||
13121,13127,13147,13151,13159,13163,13171,13177,
|
||||
13183,13187,13217,13219,13229,13241,13249,13259,
|
||||
13267,13291,13297,13309,13313,13327,13331,13337,
|
||||
13339,13367,13381,13397,13399,13411,13417,13421,
|
||||
13441,13451,13457,13463,13469,13477,13487,13499,
|
||||
13513,13523,13537,13553,13567,13577,13591,13597,
|
||||
13613,13619,13627,13633,13649,13669,13679,13681,
|
||||
13687,13691,13693,13697,13709,13711,13721,13723,
|
||||
13729,13751,13757,13759,13763,13781,13789,13799,
|
||||
13807,13829,13831,13841,13859,13873,13877,13879,
|
||||
13883,13901,13903,13907,13913,13921,13931,13933,
|
||||
13963,13967,13997,13999,14009,14011,14029,14033,
|
||||
14051,14057,14071,14081,14083,14087,14107,14143,
|
||||
14149,14153,14159,14173,14177,14197,14207,14221,
|
||||
14243,14249,14251,14281,14293,14303,14321,14323,
|
||||
14327,14341,14347,14369,14387,14389,14401,14407,
|
||||
14411,14419,14423,14431,14437,14447,14449,14461,
|
||||
14479,14489,14503,14519,14533,14537,14543,14549,
|
||||
14551,14557,14561,14563,14591,14593,14621,14627,
|
||||
14629,14633,14639,14653,14657,14669,14683,14699,
|
||||
14713,14717,14723,14731,14737,14741,14747,14753,
|
||||
14759,14767,14771,14779,14783,14797,14813,14821,
|
||||
14827,14831,14843,14851,14867,14869,14879,14887,
|
||||
14891,14897,14923,14929,14939,14947,14951,14957,
|
||||
14969,14983,15013,15017,15031,15053,15061,15073,
|
||||
15077,15083,15091,15101,15107,15121,15131,15137,
|
||||
15139,15149,15161,15173,15187,15193,15199,15217,
|
||||
15227,15233,15241,15259,15263,15269,15271,15277,
|
||||
15287,15289,15299,15307,15313,15319,15329,15331,
|
||||
15349,15359,15361,15373,15377,15383,15391,15401,
|
||||
15413,15427,15439,15443,15451,15461,15467,15473,
|
||||
15493,15497,15511,15527,15541,15551,15559,15569,
|
||||
15581,15583,15601,15607,15619,15629,15641,15643,
|
||||
15647,15649,15661,15667,15671,15679,15683,15727,
|
||||
15731,15733,15737,15739,15749,15761,15767,15773,
|
||||
15787,15791,15797,15803,15809,15817,15823,15859,
|
||||
15877,15881,15887,15889,15901,15907,15913,15919,
|
||||
15923,15937,15959,15971,15973,15991,16001,16007,
|
||||
16033,16057,16061,16063,16067,16069,16073,16087,
|
||||
16091,16097,16103,16111,16127,16139,16141,16183,
|
||||
16187,16189,16193,16217,16223,16229,16231,16249,
|
||||
16253,16267,16273,16301,16319,16333,16339,16349,
|
||||
16361,16363,16369,16381,16411,16417,16421,16427,
|
||||
16433,16447,16451,16453,16477,16481,16487,16493,
|
||||
16519,16529,16547,16553,16561,16567,16573,16603,
|
||||
16607,16619,16631,16633,16649,16651,16657,16661,
|
||||
16673,16691,16693,16699,16703,16729,16741,16747,
|
||||
16759,16763,16787,16811,16823,16829,16831,16843,
|
||||
16871,16879,16883,16889,16901,16903,16921,16927,
|
||||
16931,16937,16943,16963,16979,16981,16987,16993,
|
||||
17011,17021,17027,17029,17033,17041,17047,17053,
|
||||
17077,17093,17099,17107,17117,17123,17137,17159,
|
||||
17167,17183,17189,17191,17203,17207,17209,17231,
|
||||
17239,17257,17291,17293,17299,17317,17321,17327,
|
||||
17333,17341,17351,17359,17377,17383,17387,17389,
|
||||
17393,17401,17417,17419,17431,17443,17449,17467,
|
||||
17471,17477,17483,17489,17491,17497,17509,17519,
|
||||
17539,17551,17569,17573,17579,17581,17597,17599,
|
||||
17609,17623,17627,17657,17659,17669,17681,17683,
|
||||
17707,17713,17729,17737,17747,17749,17761,17783,
|
||||
17789,17791,17807,17827,17837,17839,17851,17863,
|
||||
#endif
|
||||
};
|
105
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/buffer.h
Executable file
105
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/buffer.h
Executable file
@ -0,0 +1,105 @@
|
||||
/* crypto/buffer/buffer.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BUFFER_H
|
||||
#define HEADER_BUFFER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef struct buf_mem_st
|
||||
{
|
||||
int length; /* current number of bytes */
|
||||
char *data;
|
||||
int max; /* size of buffer */
|
||||
} BUF_MEM;
|
||||
|
||||
BUF_MEM *BUF_MEM_new(void);
|
||||
void BUF_MEM_free(BUF_MEM *a);
|
||||
int BUF_MEM_grow(BUF_MEM *str, int len);
|
||||
int BUF_MEM_grow_clean(BUF_MEM *str, int len);
|
||||
char * BUF_strdup(const char *str);
|
||||
|
||||
/* safe string functions */
|
||||
size_t BUF_strlcpy(char *dst,const char *src,size_t siz);
|
||||
size_t BUF_strlcat(char *dst,const char *src,size_t siz);
|
||||
|
||||
|
||||
/* 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_BUF_strings(void);
|
||||
|
||||
/* Error codes for the BUF functions. */
|
||||
|
||||
/* Function codes. */
|
||||
#define BUF_F_BUF_MEM_GROW 100
|
||||
#define BUF_F_BUF_MEM_NEW 101
|
||||
#define BUF_F_BUF_STRDUP 102
|
||||
|
||||
/* Reason codes. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
119
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/cryptlib.h
Executable file
119
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/cryptlib.h
Executable file
@ -0,0 +1,119 @@
|
||||
/* crypto/cryptlib.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CRYPTLIB_H
|
||||
#define HEADER_CRYPTLIB_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#include "e_os.h"
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
#ifdef OPENSSL_USE_APPLINK
|
||||
#define BIO_FLAGS_UPLINK 0x8000
|
||||
#include "ms/uplink.h"
|
||||
#endif
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#include <openssl/buffer.h>
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/opensslconf.h>
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_SYS_VMS
|
||||
#define X509_CERT_AREA OPENSSLDIR
|
||||
#define X509_CERT_DIR OPENSSLDIR "/certs"
|
||||
#define X509_CERT_FILE OPENSSLDIR "/cert.pem"
|
||||
#define X509_PRIVATE_DIR OPENSSLDIR "/private"
|
||||
#else
|
||||
#define X509_CERT_AREA "SSLROOT:[000000]"
|
||||
#define X509_CERT_DIR "SSLCERTS:"
|
||||
#define X509_CERT_FILE "SSLCERTS:cert.pem"
|
||||
#define X509_PRIVATE_DIR "SSLPRIVATE:"
|
||||
#endif
|
||||
|
||||
#define X509_CERT_DIR_EVP "SSL_CERT_DIR"
|
||||
#define X509_CERT_FILE_EVP "SSL_CERT_FILE"
|
||||
|
||||
/* size of string representations */
|
||||
#define DECIMAL_SIZE(type) ((sizeof(type)*8+2)/3+1)
|
||||
#define HEX_SIZE(type) (sizeof(type)*2)
|
||||
|
||||
void OPENSSL_cpuid_setup(void);
|
||||
extern unsigned long OPENSSL_ia32cap_P;
|
||||
void OPENSSL_showfatal(const char *,...);
|
||||
void *OPENSSL_stderr(void);
|
||||
extern int OPENSSL_NONPIC_relocated;
|
||||
int OPENSSL_isservice(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
586
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/crypto.h
Executable file
586
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/crypto.h
Executable file
@ -0,0 +1,586 @@
|
||||
/* crypto/crypto.h */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2003 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).
|
||||
*
|
||||
*/
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
* ECDH support in OpenSSL originally developed by
|
||||
* SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CRYPTO_H
|
||||
#define HEADER_CRYPTO_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <openssl/stack.h>
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#include <openssl/safestack.h>
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
#include <openssl/opensslv.h>
|
||||
|
||||
#include <openssl/ossl_typ.h>
|
||||
|
||||
#ifdef CHARSET_EBCDIC
|
||||
#include <openssl/ebcdic.h>
|
||||
#endif
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
/* Resolve problems on some operating systems with symbol names that clash
|
||||
one way or another */
|
||||
#include <openssl/symhacks.h>
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Backward compatibility to SSLeay */
|
||||
/* This is more to be used to check the correct DLL is being used
|
||||
* in the MS world. */
|
||||
#define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER
|
||||
#define SSLEAY_VERSION 0
|
||||
/* #define SSLEAY_OPTIONS 1 no longer supported */
|
||||
#define SSLEAY_CFLAGS 2
|
||||
#define SSLEAY_BUILT_ON 3
|
||||
#define SSLEAY_PLATFORM 4
|
||||
#define SSLEAY_DIR 5
|
||||
|
||||
/* Already declared in ossl_typ.h */
|
||||
#if 0
|
||||
typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
|
||||
/* Called when a new object is created */
|
||||
typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp);
|
||||
/* Called when an object is free()ed */
|
||||
typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp);
|
||||
/* Called when we need to dup an object */
|
||||
typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
|
||||
int idx, long argl, void *argp);
|
||||
#endif
|
||||
|
||||
/* A generic structure to pass assorted data in a expandable way */
|
||||
typedef struct openssl_item_st
|
||||
{
|
||||
int code;
|
||||
void *value; /* Not used for flag attributes */
|
||||
size_t value_size; /* Max size of value for output, length for input */
|
||||
size_t *value_length; /* Returned length of value for output */
|
||||
} OPENSSL_ITEM;
|
||||
|
||||
|
||||
/* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock
|
||||
* names in cryptlib.c
|
||||
*/
|
||||
|
||||
#define CRYPTO_LOCK_ERR 1
|
||||
#define CRYPTO_LOCK_EX_DATA 2
|
||||
#define CRYPTO_LOCK_X509 3
|
||||
#define CRYPTO_LOCK_X509_INFO 4
|
||||
#define CRYPTO_LOCK_X509_PKEY 5
|
||||
#define CRYPTO_LOCK_X509_CRL 6
|
||||
#define CRYPTO_LOCK_X509_REQ 7
|
||||
#define CRYPTO_LOCK_DSA 8
|
||||
#define CRYPTO_LOCK_RSA 9
|
||||
#define CRYPTO_LOCK_EVP_PKEY 10
|
||||
#define CRYPTO_LOCK_X509_STORE 11
|
||||
#define CRYPTO_LOCK_SSL_CTX 12
|
||||
#define CRYPTO_LOCK_SSL_CERT 13
|
||||
#define CRYPTO_LOCK_SSL_SESSION 14
|
||||
#define CRYPTO_LOCK_SSL_SESS_CERT 15
|
||||
#define CRYPTO_LOCK_SSL 16
|
||||
#define CRYPTO_LOCK_SSL_METHOD 17
|
||||
#define CRYPTO_LOCK_RAND 18
|
||||
#define CRYPTO_LOCK_RAND2 19
|
||||
#define CRYPTO_LOCK_MALLOC 20
|
||||
#define CRYPTO_LOCK_BIO 21
|
||||
#define CRYPTO_LOCK_GETHOSTBYNAME 22
|
||||
#define CRYPTO_LOCK_GETSERVBYNAME 23
|
||||
#define CRYPTO_LOCK_READDIR 24
|
||||
#define CRYPTO_LOCK_RSA_BLINDING 25
|
||||
#define CRYPTO_LOCK_DH 26
|
||||
#define CRYPTO_LOCK_MALLOC2 27
|
||||
#define CRYPTO_LOCK_DSO 28
|
||||
#define CRYPTO_LOCK_DYNLOCK 29
|
||||
#define CRYPTO_LOCK_ENGINE 30
|
||||
#define CRYPTO_LOCK_UI 31
|
||||
#define CRYPTO_LOCK_ECDSA 32
|
||||
#define CRYPTO_LOCK_EC 33
|
||||
#define CRYPTO_LOCK_ECDH 34
|
||||
#define CRYPTO_LOCK_BN 35
|
||||
#define CRYPTO_LOCK_EC_PRE_COMP 36
|
||||
#define CRYPTO_LOCK_STORE 37
|
||||
#define CRYPTO_LOCK_COMP 38
|
||||
#define CRYPTO_NUM_LOCKS 39
|
||||
|
||||
#define CRYPTO_LOCK 1
|
||||
#define CRYPTO_UNLOCK 2
|
||||
#define CRYPTO_READ 4
|
||||
#define CRYPTO_WRITE 8
|
||||
|
||||
#ifndef OPENSSL_NO_LOCKING
|
||||
#ifndef CRYPTO_w_lock
|
||||
#define CRYPTO_w_lock(type) \
|
||||
CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
|
||||
#define CRYPTO_w_unlock(type) \
|
||||
CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
|
||||
#define CRYPTO_r_lock(type) \
|
||||
CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)
|
||||
#define CRYPTO_r_unlock(type) \
|
||||
CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)
|
||||
#define CRYPTO_add(addr,amount,type) \
|
||||
CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)
|
||||
#endif
|
||||
#else
|
||||
#define CRYPTO_w_lock(a)
|
||||
#define CRYPTO_w_unlock(a)
|
||||
#define CRYPTO_r_lock(a)
|
||||
#define CRYPTO_r_unlock(a)
|
||||
#define CRYPTO_add(a,b,c) ((*(a))+=(b))
|
||||
#endif
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
/* Some applications as well as some parts of OpenSSL need to allocate
|
||||
and deallocate locks in a dynamic fashion. The following typedef
|
||||
makes this possible in a type-safe manner. */
|
||||
/* struct CRYPTO_dynlock_value has to be defined by the application. */
|
||||
typedef struct
|
||||
{
|
||||
int references;
|
||||
struct CRYPTO_dynlock_value *data;
|
||||
} CRYPTO_dynlock;
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
/* The following can be used to detect memory leaks in the SSLeay library.
|
||||
* It used, it turns on malloc checking */
|
||||
|
||||
#define CRYPTO_MEM_CHECK_OFF 0x0 /* an enume */
|
||||
#define CRYPTO_MEM_CHECK_ON 0x1 /* a bit */
|
||||
#define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */
|
||||
#define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */
|
||||
|
||||
/* The following are bit values to turn on or off options connected to the
|
||||
* malloc checking functionality */
|
||||
|
||||
/* Adds time to the memory checking information */
|
||||
#define V_CRYPTO_MDEBUG_TIME 0x1 /* a bit */
|
||||
/* Adds thread number to the memory checking information */
|
||||
#define V_CRYPTO_MDEBUG_THREAD 0x2 /* a bit */
|
||||
|
||||
#define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD)
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
/* predec of the BIO type */
|
||||
typedef struct bio_st BIO_dummy;
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
struct crypto_ex_data_st
|
||||
{
|
||||
STACK *sk;
|
||||
int dummy; /* gcc is screwing up this data structure :-( */
|
||||
};
|
||||
|
||||
/* This stuff is basically class callback functions
|
||||
* The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */
|
||||
|
||||
typedef struct crypto_ex_data_func_st
|
||||
{
|
||||
long argl; /* Arbitary long */
|
||||
void *argp; /* Arbitary void * */
|
||||
CRYPTO_EX_new *new_func;
|
||||
CRYPTO_EX_free *free_func;
|
||||
CRYPTO_EX_dup *dup_func;
|
||||
} CRYPTO_EX_DATA_FUNCS;
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA
|
||||
* entry.
|
||||
*/
|
||||
|
||||
#define CRYPTO_EX_INDEX_BIO 0
|
||||
#define CRYPTO_EX_INDEX_SSL 1
|
||||
#define CRYPTO_EX_INDEX_SSL_CTX 2
|
||||
#define CRYPTO_EX_INDEX_SSL_SESSION 3
|
||||
#define CRYPTO_EX_INDEX_X509_STORE 4
|
||||
#define CRYPTO_EX_INDEX_X509_STORE_CTX 5
|
||||
#define CRYPTO_EX_INDEX_RSA 6
|
||||
#define CRYPTO_EX_INDEX_DSA 7
|
||||
#define CRYPTO_EX_INDEX_DH 8
|
||||
#define CRYPTO_EX_INDEX_ENGINE 9
|
||||
#define CRYPTO_EX_INDEX_X509 10
|
||||
#define CRYPTO_EX_INDEX_UI 11
|
||||
#define CRYPTO_EX_INDEX_ECDSA 12
|
||||
#define CRYPTO_EX_INDEX_ECDH 13
|
||||
#define CRYPTO_EX_INDEX_COMP 14
|
||||
#define CRYPTO_EX_INDEX_STORE 15
|
||||
|
||||
/* Dynamically assigned indexes start from this value (don't use directly, use
|
||||
* via CRYPTO_ex_data_new_class). */
|
||||
#define CRYPTO_EX_INDEX_USER 100
|
||||
|
||||
|
||||
/* This is the default callbacks, but we can have others as well:
|
||||
* this is needed in Win32 where the application malloc and the
|
||||
* library malloc may not be the same.
|
||||
*/
|
||||
#define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\
|
||||
malloc, realloc, free)
|
||||
|
||||
#if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD
|
||||
# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */
|
||||
# define CRYPTO_MDEBUG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Set standard debugging functions (not done by default
|
||||
* unless CRYPTO_MDEBUG is defined) */
|
||||
#define CRYPTO_malloc_debug_init() do {\
|
||||
CRYPTO_set_mem_debug_functions(\
|
||||
CRYPTO_dbg_malloc,\
|
||||
CRYPTO_dbg_realloc,\
|
||||
CRYPTO_dbg_free,\
|
||||
CRYPTO_dbg_set_options,\
|
||||
CRYPTO_dbg_get_options);\
|
||||
} while(0)
|
||||
|
||||
int CRYPTO_mem_ctrl(int mode);
|
||||
int CRYPTO_is_mem_check_on(void);
|
||||
|
||||
/* for applications */
|
||||
#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON)
|
||||
#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF)
|
||||
|
||||
/* for library-internal use */
|
||||
#define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE)
|
||||
#define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
|
||||
#define is_MemCheck_on() CRYPTO_is_mem_check_on()
|
||||
|
||||
#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
|
||||
#define OPENSSL_realloc(addr,num) \
|
||||
CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
|
||||
#define OPENSSL_realloc_clean(addr,old_num,num) \
|
||||
CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)
|
||||
#define OPENSSL_remalloc(addr,num) \
|
||||
CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
|
||||
#define OPENSSL_freeFunc CRYPTO_free
|
||||
#define OPENSSL_free(addr) CRYPTO_free(addr)
|
||||
|
||||
#define OPENSSL_malloc_locked(num) \
|
||||
CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
|
||||
#define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)
|
||||
|
||||
|
||||
const char *SSLeay_version(int type);
|
||||
unsigned long SSLeay(void);
|
||||
|
||||
int OPENSSL_issetugid(void);
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
/* An opaque type representing an implementation of "ex_data" support */
|
||||
typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL;
|
||||
/* Return an opaque pointer to the current "ex_data" implementation */
|
||||
const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void);
|
||||
/* Sets the "ex_data" implementation to be used (if it's not too late) */
|
||||
int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);
|
||||
/* Get a new "ex_data" class, and return the corresponding "class_index" */
|
||||
int CRYPTO_ex_data_new_class(void);
|
||||
/* Within a given class, get/register a new index */
|
||||
int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
|
||||
CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
|
||||
CRYPTO_EX_free *free_func);
|
||||
/* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given
|
||||
* class (invokes whatever per-class callbacks are applicable) */
|
||||
int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
|
||||
int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
|
||||
CRYPTO_EX_DATA *from);
|
||||
void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
|
||||
/* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index
|
||||
* (relative to the class type involved) */
|
||||
int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
|
||||
void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx);
|
||||
/* This function cleans up all "ex_data" state. It mustn't be called under
|
||||
* potential race-conditions. */
|
||||
void CRYPTO_cleanup_all_ex_data(void);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
int CRYPTO_get_new_lockid(char *name);
|
||||
|
||||
int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */
|
||||
void CRYPTO_lock(int mode, int type,const char *file,int line);
|
||||
void CRYPTO_set_locking_callback(void (*func)(int mode,int type,
|
||||
const char *file,int line));
|
||||
void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file,
|
||||
int line);
|
||||
void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
|
||||
const char *file, int line));
|
||||
int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type,
|
||||
const char *file,int line);
|
||||
void CRYPTO_set_id_callback(unsigned long (*func)(void));
|
||||
unsigned long (*CRYPTO_get_id_callback(void))(void);
|
||||
unsigned long CRYPTO_thread_id(void);
|
||||
const char *CRYPTO_get_lock_name(int type);
|
||||
int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file,
|
||||
int line);
|
||||
|
||||
int CRYPTO_get_new_dynlockid(void);
|
||||
void CRYPTO_destroy_dynlockid(int i);
|
||||
struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);
|
||||
void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line));
|
||||
void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line));
|
||||
void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line));
|
||||
struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line);
|
||||
void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line);
|
||||
void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line);
|
||||
|
||||
/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions --
|
||||
* call the latter last if you need different functions */
|
||||
int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *));
|
||||
int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
|
||||
int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int),
|
||||
void *(*r)(void *,size_t,const char *,int),
|
||||
void (*f)(void *));
|
||||
int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int),
|
||||
void (*free_func)(void *));
|
||||
int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
|
||||
void (*r)(void *,void *,int,const char *,int,int),
|
||||
void (*f)(void *,int),
|
||||
void (*so)(long),
|
||||
long (*go)(void));
|
||||
void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
|
||||
void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
|
||||
void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int),
|
||||
void *(**r)(void *, size_t,const char *,int),
|
||||
void (**f)(void *));
|
||||
void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int),
|
||||
void (**f)(void *));
|
||||
void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
|
||||
void (**r)(void *,void *,int,const char *,int,int),
|
||||
void (**f)(void *,int),
|
||||
void (**so)(long),
|
||||
long (**go)(void));
|
||||
|
||||
void *CRYPTO_malloc_locked(int num, const char *file, int line);
|
||||
void CRYPTO_free_locked(void *);
|
||||
void *CRYPTO_malloc(int num, const char *file, int line);
|
||||
void CRYPTO_free(void *);
|
||||
void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
|
||||
void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file,
|
||||
int line);
|
||||
void *CRYPTO_remalloc(void *addr,int num, const char *file, int line);
|
||||
|
||||
void OPENSSL_cleanse(void *ptr, size_t len);
|
||||
|
||||
void CRYPTO_set_mem_debug_options(long bits);
|
||||
long CRYPTO_get_mem_debug_options(void);
|
||||
|
||||
#define CRYPTO_push_info(info) \
|
||||
CRYPTO_push_info_(info, __FILE__, __LINE__);
|
||||
int CRYPTO_push_info_(const char *info, const char *file, int line);
|
||||
int CRYPTO_pop_info(void);
|
||||
int CRYPTO_remove_all_info(void);
|
||||
|
||||
|
||||
/* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro;
|
||||
* used as default in CRYPTO_MDEBUG compilations): */
|
||||
/* The last argument has the following significance:
|
||||
*
|
||||
* 0: called before the actual memory allocation has taken place
|
||||
* 1: called after the actual memory allocation has taken place
|
||||
*/
|
||||
void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p);
|
||||
void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p);
|
||||
void CRYPTO_dbg_free(void *addr,int before_p);
|
||||
/* Tell the debugging code about options. By default, the following values
|
||||
* apply:
|
||||
*
|
||||
* 0: Clear all options.
|
||||
* V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option.
|
||||
* V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option.
|
||||
* V_CRYPTO_MDEBUG_ALL (3): 1 + 2
|
||||
*/
|
||||
void CRYPTO_dbg_set_options(long bits);
|
||||
long CRYPTO_dbg_get_options(void);
|
||||
|
||||
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
void CRYPTO_mem_leaks_fp(FILE *);
|
||||
#endif
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
void CRYPTO_mem_leaks(struct bio_st *bio);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
/* unsigned long order, char *file, int line, int num_bytes, char *addr */
|
||||
typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
|
||||
void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
/* die if we have to */
|
||||
void OpenSSLDie(const char *file,int line,const char *assertion);
|
||||
#define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))
|
||||
#endif
|
||||
#define OPENSSL_assert(e)
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
unsigned long *OPENSSL_ia32cap_loc(void);
|
||||
#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))
|
||||
|
||||
/* 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_CRYPTO_strings(void);
|
||||
|
||||
/* Error codes for the CRYPTO functions. */
|
||||
|
||||
/* Function codes. */
|
||||
#define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100
|
||||
#define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103
|
||||
#define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101
|
||||
#define CRYPTO_F_CRYPTO_SET_EX_DATA 102
|
||||
#define CRYPTO_F_DEF_ADD_INDEX 104
|
||||
#define CRYPTO_F_DEF_GET_CLASS 105
|
||||
#define CRYPTO_F_INT_DUP_EX_DATA 106
|
||||
#define CRYPTO_F_INT_FREE_EX_DATA 107
|
||||
#define CRYPTO_F_INT_NEW_EX_DATA 108
|
||||
|
||||
/* Reason codes. */
|
||||
#define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
244
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/des.h
Executable file
244
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/des.h
Executable file
@ -0,0 +1,244 @@
|
||||
/* crypto/des/des.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_NEW_DES_H
|
||||
#define HEADER_NEW_DES_H
|
||||
|
||||
#ifdef OPENSSL_NO_DES
|
||||
#error DES is disabled.
|
||||
#endif
|
||||
|
||||
#include <openssl/opensslconf.h> /* DES_LONG */
|
||||
#include <openssl/e_os2.h> /* OPENSSL_EXTERN */
|
||||
|
||||
#ifdef OPENSSL_BUILD_SHLIBCRYPTO
|
||||
# undef OPENSSL_EXTERN
|
||||
# define OPENSSL_EXTERN OPENSSL_EXPORT
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef unsigned char DES_cblock[8];
|
||||
typedef /* const */ unsigned char const_DES_cblock[8];
|
||||
/* With "const", gcc 2.8.1 on Solaris thinks that DES_cblock *
|
||||
* and const_DES_cblock * are incompatible pointer types. */
|
||||
|
||||
typedef struct DES_ks
|
||||
{
|
||||
union
|
||||
{
|
||||
DES_cblock cblock;
|
||||
/* make sure things are correct size on machines with
|
||||
* 8 byte longs */
|
||||
DES_LONG deslong[2];
|
||||
} ks[16];
|
||||
} DES_key_schedule;
|
||||
|
||||
#ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT
|
||||
# ifndef OPENSSL_ENABLE_OLD_DES_SUPPORT
|
||||
# define OPENSSL_ENABLE_OLD_DES_SUPPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef OPENSSL_ENABLE_OLD_DES_SUPPORT
|
||||
# include <openssl/des_old.h>
|
||||
#endif
|
||||
|
||||
#define DES_KEY_SZ (sizeof(DES_cblock))
|
||||
#define DES_SCHEDULE_SZ (sizeof(DES_key_schedule))
|
||||
|
||||
#define DES_ENCRYPT 1
|
||||
#define DES_DECRYPT 0
|
||||
|
||||
#define DES_CBC_MODE 0
|
||||
#define DES_PCBC_MODE 1
|
||||
|
||||
#define DES_ecb2_encrypt(i,o,k1,k2,e) \
|
||||
DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
|
||||
|
||||
#define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
|
||||
DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
|
||||
|
||||
#define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
|
||||
DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
|
||||
|
||||
#define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
|
||||
DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
|
||||
|
||||
OPENSSL_DECLARE_GLOBAL(int,DES_check_key); /* defaults to false */
|
||||
#define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key)
|
||||
OPENSSL_DECLARE_GLOBAL(int,DES_rw_mode); /* defaults to DES_PCBC_MODE */
|
||||
#define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode)
|
||||
|
||||
const char *DES_options(void);
|
||||
void DES_ecb3_encrypt(const unsigned char *input, unsigned char *output,
|
||||
DES_key_schedule *ks1,DES_key_schedule *ks2,
|
||||
DES_key_schedule *ks3, int enc);
|
||||
DES_LONG DES_cbc_cksum(const unsigned char *input,DES_cblock *output,
|
||||
long length,DES_key_schedule *schedule,
|
||||
const_DES_cblock *ivec);
|
||||
/* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */
|
||||
void DES_cbc_encrypt(const unsigned char *input,unsigned char *output,
|
||||
long length,DES_key_schedule *schedule,DES_cblock *ivec,
|
||||
int enc);
|
||||
void DES_ncbc_encrypt(const unsigned char *input,unsigned char *output,
|
||||
long length,DES_key_schedule *schedule,DES_cblock *ivec,
|
||||
int enc);
|
||||
void DES_xcbc_encrypt(const unsigned char *input,unsigned char *output,
|
||||
long length,DES_key_schedule *schedule,DES_cblock *ivec,
|
||||
const_DES_cblock *inw,const_DES_cblock *outw,int enc);
|
||||
void DES_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
|
||||
long length,DES_key_schedule *schedule,DES_cblock *ivec,
|
||||
int enc);
|
||||
void DES_ecb_encrypt(const_DES_cblock *input,DES_cblock *output,
|
||||
DES_key_schedule *ks,int enc);
|
||||
|
||||
/* This is the DES encryption function that gets called by just about
|
||||
every other DES routine in the library. You should not use this
|
||||
function except to implement 'modes' of DES. I say this because the
|
||||
functions that call this routine do the conversion from 'char *' to
|
||||
long, and this needs to be done to make sure 'non-aligned' memory
|
||||
access do not occur. The characters are loaded 'little endian'.
|
||||
Data is a pointer to 2 unsigned long's and ks is the
|
||||
DES_key_schedule to use. enc, is non zero specifies encryption,
|
||||
zero if decryption. */
|
||||
void DES_encrypt1(DES_LONG *data,DES_key_schedule *ks, int enc);
|
||||
|
||||
/* This functions is the same as DES_encrypt1() except that the DES
|
||||
initial permutation (IP) and final permutation (FP) have been left
|
||||
out. As for DES_encrypt1(), you should not use this function.
|
||||
It is used by the routines in the library that implement triple DES.
|
||||
IP() DES_encrypt2() DES_encrypt2() DES_encrypt2() FP() is the same
|
||||
as DES_encrypt1() DES_encrypt1() DES_encrypt1() except faster :-). */
|
||||
void DES_encrypt2(DES_LONG *data,DES_key_schedule *ks, int enc);
|
||||
|
||||
void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,
|
||||
DES_key_schedule *ks2, DES_key_schedule *ks3);
|
||||
void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
|
||||
DES_key_schedule *ks2, DES_key_schedule *ks3);
|
||||
void DES_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output,
|
||||
long length,
|
||||
DES_key_schedule *ks1,DES_key_schedule *ks2,
|
||||
DES_key_schedule *ks3,DES_cblock *ivec,int enc);
|
||||
void DES_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out,
|
||||
long length,
|
||||
DES_key_schedule *ks1,DES_key_schedule *ks2,
|
||||
DES_key_schedule *ks3,
|
||||
DES_cblock *ivec1,DES_cblock *ivec2,
|
||||
int enc);
|
||||
void DES_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out,
|
||||
long length,DES_key_schedule *ks1,
|
||||
DES_key_schedule *ks2,DES_key_schedule *ks3,
|
||||
DES_cblock *ivec,int *num,int enc);
|
||||
void DES_ede3_cfb_encrypt(const unsigned char *in,unsigned char *out,
|
||||
int numbits,long length,DES_key_schedule *ks1,
|
||||
DES_key_schedule *ks2,DES_key_schedule *ks3,
|
||||
DES_cblock *ivec,int enc);
|
||||
void DES_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out,
|
||||
long length,DES_key_schedule *ks1,
|
||||
DES_key_schedule *ks2,DES_key_schedule *ks3,
|
||||
DES_cblock *ivec,int *num);
|
||||
|
||||
void DES_xwhite_in2out(const_DES_cblock *DES_key,const_DES_cblock *in_white,
|
||||
DES_cblock *out_white);
|
||||
|
||||
int DES_enc_read(int fd,void *buf,int len,DES_key_schedule *sched,
|
||||
DES_cblock *iv);
|
||||
int DES_enc_write(int fd,const void *buf,int len,DES_key_schedule *sched,
|
||||
DES_cblock *iv);
|
||||
char *DES_fcrypt(const char *buf,const char *salt, char *ret);
|
||||
char *DES_crypt(const char *buf,const char *salt);
|
||||
void DES_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
|
||||
long length,DES_key_schedule *schedule,DES_cblock *ivec);
|
||||
void DES_pcbc_encrypt(const unsigned char *input,unsigned char *output,
|
||||
long length,DES_key_schedule *schedule,DES_cblock *ivec,
|
||||
int enc);
|
||||
DES_LONG DES_quad_cksum(const unsigned char *input,DES_cblock output[],
|
||||
long length,int out_count,DES_cblock *seed);
|
||||
int DES_random_key(DES_cblock *ret);
|
||||
void DES_set_odd_parity(DES_cblock *key);
|
||||
int DES_check_key_parity(const_DES_cblock *key);
|
||||
int DES_is_weak_key(const_DES_cblock *key);
|
||||
/* DES_set_key (= set_key = DES_key_sched = key_sched) calls
|
||||
* DES_set_key_checked if global variable DES_check_key is set,
|
||||
* DES_set_key_unchecked otherwise. */
|
||||
int DES_set_key(const_DES_cblock *key,DES_key_schedule *schedule);
|
||||
int DES_key_sched(const_DES_cblock *key,DES_key_schedule *schedule);
|
||||
int DES_set_key_checked(const_DES_cblock *key,DES_key_schedule *schedule);
|
||||
void DES_set_key_unchecked(const_DES_cblock *key,DES_key_schedule *schedule);
|
||||
void DES_string_to_key(const char *str,DES_cblock *key);
|
||||
void DES_string_to_2keys(const char *str,DES_cblock *key1,DES_cblock *key2);
|
||||
void DES_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length,
|
||||
DES_key_schedule *schedule,DES_cblock *ivec,int *num,
|
||||
int enc);
|
||||
void DES_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length,
|
||||
DES_key_schedule *schedule,DES_cblock *ivec,int *num);
|
||||
|
||||
int DES_read_password(DES_cblock *key, const char *prompt, int verify);
|
||||
int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt,
|
||||
int verify);
|
||||
|
||||
#define DES_fixup_key_parity DES_set_odd_parity
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
237
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/dh.h
Executable file
237
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/dh.h
Executable file
@ -0,0 +1,237 @@
|
||||
/* crypto/dh/dh.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_DH_H
|
||||
#define HEADER_DH_H
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
#ifdef OPENSSL_NO_DH
|
||||
#error DH is disabled.
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_BIO
|
||||
#include <openssl/bio.h>
|
||||
#endif
|
||||
#include <openssl/ossl_typ.h>
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
#include <openssl/bn.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <openssl/ossl_typ.h>
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
|
||||
|
||||
#define DH_FLAG_CACHE_MONT_P 0x01
|
||||
#define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH
|
||||
* implementation now uses constant time
|
||||
* modular exponentiation for secret exponents
|
||||
* by default. This flag causes the
|
||||
* faster variable sliding window method to
|
||||
* be used for all exponents.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Already defined in ossl_typ.h */
|
||||
/* typedef struct dh_st DH; */
|
||||
/* typedef struct dh_method DH_METHOD; */
|
||||
|
||||
struct dh_method
|
||||
{
|
||||
const char *name;
|
||||
/* Methods here */
|
||||
int (*generate_key)(DH *dh);
|
||||
int (*compute_key)(unsigned char *key,const BIGNUM *pub_key,DH *dh);
|
||||
int (*bn_mod_exp)(const DH *dh, BIGNUM *r, const BIGNUM *a,
|
||||
const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
|
||||
BN_MONT_CTX *m_ctx); /* Can be null */
|
||||
|
||||
int (*init)(DH *dh);
|
||||
int (*finish)(DH *dh);
|
||||
int flags;
|
||||
char *app_data;
|
||||
/* If this is non-NULL, it will be used to generate parameters */
|
||||
int (*generate_params)(DH *dh, int prime_len, int generator, BN_GENCB *cb);
|
||||
};
|
||||
|
||||
struct dh_st
|
||||
{
|
||||
/* This first argument is used to pick up errors when
|
||||
* a DH is passed instead of a EVP_PKEY */
|
||||
int pad;
|
||||
int version;
|
||||
BIGNUM *p;
|
||||
BIGNUM *g;
|
||||
int length; /* optional */
|
||||
BIGNUM *pub_key; /* g^x */
|
||||
BIGNUM *priv_key; /* x */
|
||||
|
||||
int flags;
|
||||
BN_MONT_CTX *method_mont_p;
|
||||
/* Place holders if we want to do X9.42 DH */
|
||||
BIGNUM *q;
|
||||
BIGNUM *j;
|
||||
unsigned char *seed;
|
||||
int seedlen;
|
||||
BIGNUM *counter;
|
||||
|
||||
int references;
|
||||
CRYPTO_EX_DATA ex_data;
|
||||
const DH_METHOD *meth;
|
||||
ENGINE *engine;
|
||||
};
|
||||
|
||||
#define DH_GENERATOR_2 2
|
||||
/* #define DH_GENERATOR_3 3 */
|
||||
#define DH_GENERATOR_5 5
|
||||
|
||||
/* DH_check error codes */
|
||||
#define DH_CHECK_P_NOT_PRIME 0x01
|
||||
#define DH_CHECK_P_NOT_SAFE_PRIME 0x02
|
||||
#define DH_UNABLE_TO_CHECK_GENERATOR 0x04
|
||||
#define DH_NOT_SUITABLE_GENERATOR 0x08
|
||||
|
||||
/* DH_check_pub_key error codes */
|
||||
#define DH_CHECK_PUBKEY_TOO_SMALL 0x01
|
||||
#define DH_CHECK_PUBKEY_TOO_LARGE 0x02
|
||||
|
||||
/* primes p where (p-1)/2 is prime too are called "safe"; we define
|
||||
this for backward compatibility: */
|
||||
#define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#define DHparams_dup(x) ASN1_dup_of_const(DH,i2d_DHparams,d2i_DHparams,x)
|
||||
#define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \
|
||||
(char *(*)())d2i_DHparams,(fp),(unsigned char **)(x))
|
||||
#define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \
|
||||
(unsigned char *)(x))
|
||||
#define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x)
|
||||
#define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x)
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
const DH_METHOD *DH_OpenSSL(void);
|
||||
|
||||
void DH_set_default_method(const DH_METHOD *meth);
|
||||
const DH_METHOD *DH_get_default_method(void);
|
||||
int DH_set_method(DH *dh, const DH_METHOD *meth);
|
||||
DH *DH_new_method(ENGINE *engine);
|
||||
|
||||
DH * DH_new(void);
|
||||
void DH_free(DH *dh);
|
||||
int DH_up_ref(DH *dh);
|
||||
int DH_size(const DH *dh);
|
||||
int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
|
||||
CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
|
||||
int DH_set_ex_data(DH *d, int idx, void *arg);
|
||||
void *DH_get_ex_data(DH *d, int idx);
|
||||
|
||||
/* Deprecated version */
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
DH * DH_generate_parameters(int prime_len,int generator,
|
||||
void (*callback)(int,int,void *),void *cb_arg);
|
||||
#endif /* !defined(OPENSSL_NO_DEPRECATED) */
|
||||
|
||||
/* New version */
|
||||
int DH_generate_parameters_ex(DH *dh, int prime_len,int generator, BN_GENCB *cb);
|
||||
|
||||
int DH_check(const DH *dh,int *codes);
|
||||
int DH_check_pub_key(const DH *dh,const BIGNUM *pub_key, int *codes);
|
||||
int DH_generate_key(DH *dh);
|
||||
int DH_compute_key(unsigned char *key,const BIGNUM *pub_key,DH *dh);
|
||||
DH * d2i_DHparams(DH **a,const unsigned char **pp, long length);
|
||||
int i2d_DHparams(const DH *a,unsigned char **pp);
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
int DHparams_print_fp(FILE *fp, const DH *x);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_BIO
|
||||
int DHparams_print(BIO *bp, const DH *x);
|
||||
#else
|
||||
int DHparams_print(char *bp, const DH *x);
|
||||
#endif
|
||||
|
||||
/* 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_DH_strings(void);
|
||||
|
||||
/* Error codes for the DH functions. */
|
||||
|
||||
/* Function codes. */
|
||||
#define DH_F_COMPUTE_KEY 102
|
||||
#define DH_F_DHPARAMS_PRINT 100
|
||||
#define DH_F_DHPARAMS_PRINT_FP 101
|
||||
#define DH_F_DH_BUILTIN_GENPARAMS 106
|
||||
#define DH_F_DH_NEW_METHOD 105
|
||||
#define DH_F_GENERATE_KEY 103
|
||||
#define DH_F_GENERATE_PARAMETERS 104
|
||||
|
||||
/* Reason codes. */
|
||||
#define DH_R_BAD_GENERATOR 101
|
||||
#define DH_R_INVALID_PUBKEY 102
|
||||
#define DH_R_NO_PRIVATE_VALUE 100
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
673
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/e_os.h
Executable file
673
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/e_os.h
Executable file
@ -0,0 +1,673 @@
|
||||
/* e_os.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_E_OS_H
|
||||
#define HEADER_E_OS_H
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#include <openssl/opensslconf.h>
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
/* <openssl/e_os2.h> contains what we can justify to make visible
|
||||
* to the outside; this file e_os.h is not part of the exported
|
||||
* interface. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Used to checking reference counts, most while doing perl5 stuff :-) */
|
||||
#ifdef REF_PRINT
|
||||
#undef REF_PRINT
|
||||
#define REF_PRINT(a,b) fprintf(stderr,"%08X:%4d:%s\n",(int)b,b->references,a)
|
||||
#endif
|
||||
|
||||
#ifndef DEVRANDOM
|
||||
/* set this to a comma-separated list of 'random' device files to try out.
|
||||
* My default, we will try to read at least one of these files */
|
||||
#define DEVRANDOM "/dev/urandom","/dev/random","/dev/srandom"
|
||||
#endif
|
||||
#ifndef DEVRANDOM_EGD
|
||||
/* set this to a comma-seperated list of 'egd' sockets to try out. These
|
||||
* sockets will be tried in the order listed in case accessing the device files
|
||||
* listed in DEVRANDOM did not return enough entropy. */
|
||||
#define DEVRANDOM_EGD "/var/run/egd-pool","/dev/egd-pool","/etc/egd-pool","/etc/entropy"
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_SYS_VXWORKS)
|
||||
# define NO_SYS_PARAM_H
|
||||
# define NO_CHMOD
|
||||
# define NO_SYSLOG
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
|
||||
# if macintosh==1
|
||||
# ifndef MAC_OS_GUSI_SOURCE
|
||||
# define MAC_OS_pre_X
|
||||
# define NO_SYS_TYPES_H
|
||||
typedef long ssize_t;
|
||||
# endif
|
||||
# define NO_SYS_PARAM_H
|
||||
# define NO_CHMOD
|
||||
# define NO_SYSLOG
|
||||
# undef DEVRANDOM
|
||||
# define GETPID_IS_MEANINGLESS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/********************************************************************
|
||||
The Microsoft section
|
||||
********************************************************************/
|
||||
/* The following is used becaue of the small stack in some
|
||||
* Microsoft operating systems */
|
||||
#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYSNAME_WIN32)
|
||||
# define MS_STATIC static
|
||||
#else
|
||||
# define MS_STATIC
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_SYS_WIN32) && !defined(WIN32)
|
||||
# define WIN32
|
||||
#endif
|
||||
#if defined(OPENSSL_SYS_WIN16) && !defined(WIN16)
|
||||
# define WIN16
|
||||
#endif
|
||||
#if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS)
|
||||
# define WINDOWS
|
||||
#endif
|
||||
#if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS)
|
||||
# define MSDOS
|
||||
#endif
|
||||
|
||||
#if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)
|
||||
# define GETPID_IS_MEANINGLESS
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define get_last_sys_error() GetLastError()
|
||||
#define clear_sys_error() SetLastError(0)
|
||||
#if !defined(WINNT)
|
||||
#define WIN_CONSOLE_BUG
|
||||
#endif
|
||||
#else
|
||||
#define get_last_sys_error() errno
|
||||
#define clear_sys_error() errno=0
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#define get_last_socket_error() WSAGetLastError()
|
||||
#define clear_socket_error() WSASetLastError(0)
|
||||
#define readsocket(s,b,n) recv((s),(b),(n),0)
|
||||
#define writesocket(s,b,n) send((s),(b),(n),0)
|
||||
#define EADDRINUSE WSAEADDRINUSE
|
||||
#elif defined(__DJGPP__)
|
||||
#define WATT32
|
||||
#define get_last_socket_error() errno
|
||||
#define clear_socket_error() errno=0
|
||||
#define closesocket(s) close_s(s)
|
||||
#define readsocket(s,b,n) read_s(s,b,n)
|
||||
#define writesocket(s,b,n) send(s,b,n,0)
|
||||
#elif defined(MAC_OS_pre_X)
|
||||
#define get_last_socket_error() errno
|
||||
#define clear_socket_error() errno=0
|
||||
#define closesocket(s) MacSocket_close(s)
|
||||
#define readsocket(s,b,n) MacSocket_recv((s),(b),(n),true)
|
||||
#define writesocket(s,b,n) MacSocket_send((s),(b),(n))
|
||||
#elif defined(OPENSSL_SYS_VMS)
|
||||
#define get_last_socket_error() errno
|
||||
#define clear_socket_error() errno=0
|
||||
#define ioctlsocket(a,b,c) ioctl(a,b,c)
|
||||
#define closesocket(s) close(s)
|
||||
#define readsocket(s,b,n) recv((s),(b),(n),0)
|
||||
#define writesocket(s,b,n) send((s),(b),(n),0)
|
||||
#elif defined(OPENSSL_SYS_VXWORKS)
|
||||
#define get_last_socket_error() errno
|
||||
#define clear_socket_error() errno=0
|
||||
#define ioctlsocket(a,b,c) ioctl((a),(b),(int)(c))
|
||||
#define closesocket(s) close(s)
|
||||
#define readsocket(s,b,n) read((s),(b),(n))
|
||||
#define writesocket(s,b,n) write((s),(char *)(b),(n))
|
||||
#elif defined(OPENSSL_SYS_NETWARE)
|
||||
#if defined(NETWARE_BSDSOCK)
|
||||
#define get_last_socket_error() errno
|
||||
#define clear_socket_error() errno=0
|
||||
#define closesocket(s) close(s)
|
||||
#define readsocket(s,b,n) recv((s),(b),(n),0)
|
||||
#define writesocket(s,b,n) send((s),(b),(n),0)
|
||||
#else
|
||||
#define get_last_socket_error() WSAGetLastError()
|
||||
#define clear_socket_error() WSASetLastError(0)
|
||||
#define readsocket(s,b,n) recv((s),(b),(n),0)
|
||||
#define writesocket(s,b,n) send((s),(b),(n),0)
|
||||
#endif
|
||||
#else
|
||||
#define get_last_socket_error() errno
|
||||
#define clear_socket_error() errno=0
|
||||
#define ioctlsocket(a,b,c) ioctl(a,b,c)
|
||||
#define closesocket(s) close(s)
|
||||
#define readsocket(s,b,n) read((s),(b),(n))
|
||||
#define writesocket(s,b,n) write((s),(b),(n))
|
||||
#endif
|
||||
|
||||
#ifdef WIN16
|
||||
# define MS_CALLBACK _far _loadds
|
||||
# define MS_FAR _far
|
||||
#else
|
||||
# define MS_CALLBACK
|
||||
# define MS_FAR
|
||||
#endif
|
||||
|
||||
#ifdef OPENSSL_NO_STDIO
|
||||
# undef OPENSSL_NO_FP_API
|
||||
# define OPENSSL_NO_FP_API
|
||||
#endif
|
||||
|
||||
#if (defined(WINDOWS) || defined(MSDOS))
|
||||
|
||||
# ifdef __DJGPP__
|
||||
# include <unistd.h>
|
||||
# include <sys/stat.h>
|
||||
# include <sys/socket.h>
|
||||
# include <tcp.h>
|
||||
# include <netdb.h>
|
||||
# define _setmode setmode
|
||||
# define _O_TEXT O_TEXT
|
||||
# define _O_BINARY O_BINARY
|
||||
# undef DEVRANDOM
|
||||
# define DEVRANDOM "/dev/urandom\x24"
|
||||
# endif /* __DJGPP__ */
|
||||
|
||||
# ifndef S_IFDIR
|
||||
# define S_IFDIR _S_IFDIR
|
||||
# endif
|
||||
|
||||
# ifndef S_IFMT
|
||||
# define S_IFMT _S_IFMT
|
||||
# endif
|
||||
|
||||
# if !defined(WINNT) && !defined(__DJGPP__)
|
||||
# define NO_SYSLOG
|
||||
# endif
|
||||
# define NO_DIRENT
|
||||
|
||||
# ifdef WINDOWS
|
||||
# if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT)
|
||||
/*
|
||||
* Defining _WIN32_WINNT here in e_os.h implies certain "discipline."
|
||||
* Most notably we ought to check for availability of each specific
|
||||
* routine with GetProcAddress() and/or quard NT-specific calls with
|
||||
* GetVersion() < 0x80000000. One can argue that in latter "or" case
|
||||
* we ought to /DELAYLOAD some .DLLs in order to protect ourselves
|
||||
* against run-time link errors. This doesn't seem to be necessary,
|
||||
* because it turned out that already Windows 95, first non-NT Win32
|
||||
* implementation, is equipped with at least NT 3.51 stubs, dummy
|
||||
* routines with same name, but which do nothing. Meaning that it's
|
||||
* apparently appropriate to guard generic NT calls with GetVersion
|
||||
* alone, while NT 4.0 and above calls ought to be additionally
|
||||
* checked upon with GetProcAddress.
|
||||
*/
|
||||
# define _WIN32_WINNT 0x0400
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# include <stddef.h>
|
||||
# include <errno.h>
|
||||
# include <string.h>
|
||||
# ifdef _WIN64
|
||||
# define strlen(s) _strlen31(s)
|
||||
/* cut strings to 2GB */
|
||||
static unsigned int _strlen31(const char *str)
|
||||
{
|
||||
unsigned int len=0;
|
||||
while (*str && len<0x80000000U) str++, len++;
|
||||
return len&0x7FFFFFFF;
|
||||
}
|
||||
# endif
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
# include <io.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
# ifdef OPENSSL_SYS_WINCE
|
||||
# include <winsock_extras.h>
|
||||
# endif
|
||||
|
||||
# define ssize_t long
|
||||
|
||||
# if defined (__BORLANDC__)
|
||||
# define _setmode setmode
|
||||
# define _O_TEXT O_TEXT
|
||||
# define _O_BINARY O_BINARY
|
||||
# define _int64 __int64
|
||||
# define _kbhit kbhit
|
||||
# endif
|
||||
|
||||
# if defined(WIN16) && defined(SSLEAY) && defined(_WINEXITNOPERSIST)
|
||||
# define EXIT(n) _wsetexit(_WINEXITNOPERSIST)
|
||||
# define OPENSSL_EXIT(n) do { if (n == 0) EXIT(n); return(n); } while(0)
|
||||
# else
|
||||
# define EXIT(n) exit(n)
|
||||
# endif
|
||||
# define LIST_SEPARATOR_CHAR ';'
|
||||
# ifndef X_OK
|
||||
# define X_OK 0
|
||||
# endif
|
||||
# ifndef W_OK
|
||||
# define W_OK 2
|
||||
# endif
|
||||
# ifndef R_OK
|
||||
# define R_OK 4
|
||||
# endif
|
||||
# define OPENSSL_CONF "openssl.cnf"
|
||||
# define SSLEAY_CONF OPENSSL_CONF
|
||||
# define NUL_DEV "nul"
|
||||
# define RFILE ".rnd"
|
||||
# ifdef OPENSSL_SYS_WINCE
|
||||
# define DEFAULT_HOME ""
|
||||
# else
|
||||
# define DEFAULT_HOME "C:"
|
||||
# endif
|
||||
|
||||
#else /* The non-microsoft world world */
|
||||
|
||||
# ifdef OPENSSL_SYS_VMS
|
||||
# define VMS 1
|
||||
/* some programs don't include stdlib, so exit() and others give implicit
|
||||
function warnings */
|
||||
# include <stdlib.h>
|
||||
# if defined(__DECC)
|
||||
# include <unistd.h>
|
||||
# else
|
||||
# include <unixlib.h>
|
||||
# endif
|
||||
# define OPENSSL_CONF "openssl.cnf"
|
||||
# define SSLEAY_CONF OPENSSL_CONF
|
||||
# define RFILE ".rnd"
|
||||
# define LIST_SEPARATOR_CHAR ','
|
||||
# define NUL_DEV "NLA0:"
|
||||
/* We don't have any well-defined random devices on VMS, yet... */
|
||||
# undef DEVRANDOM
|
||||
/* We need to do this since VMS has the following coding on status codes:
|
||||
|
||||
Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ...
|
||||
The important thing to know is that odd numbers are considered
|
||||
good, while even ones are considered errors.
|
||||
Bits 3-15: actual status number
|
||||
Bits 16-27: facility number. 0 is considered "unknown"
|
||||
Bits 28-31: control bits. If bit 28 is set, the shell won't try to
|
||||
output the message (which, for random codes, just looks ugly)
|
||||
|
||||
So, what we do here is to change 0 to 1 to get the default success status,
|
||||
and everything else is shifted up to fit into the status number field, and
|
||||
the status is tagged as an error, which I believe is what is wanted here.
|
||||
-- Richard Levitte
|
||||
*/
|
||||
# define EXIT(n) do { int __VMS_EXIT = n; \
|
||||
if (__VMS_EXIT == 0) \
|
||||
__VMS_EXIT = 1; \
|
||||
else \
|
||||
__VMS_EXIT = (n << 3) | 2; \
|
||||
__VMS_EXIT |= 0x10000000; \
|
||||
exit(__VMS_EXIT); } while(0)
|
||||
# define NO_SYS_PARAM_H
|
||||
|
||||
# elif defined(OPENSSL_SYS_NETWARE)
|
||||
# include <fcntl.h>
|
||||
# include <unistd.h>
|
||||
# define NO_SYS_TYPES_H
|
||||
# undef DEVRANDOM
|
||||
# ifdef NETWARE_CLIB
|
||||
# define getpid GetThreadID
|
||||
# endif
|
||||
# define NO_SYSLOG
|
||||
# define _setmode setmode
|
||||
# define _kbhit kbhit
|
||||
# define _O_TEXT O_TEXT
|
||||
# define _O_BINARY O_BINARY
|
||||
# define OPENSSL_CONF "openssl.cnf"
|
||||
# define SSLEAY_CONF OPENSSL_CONF
|
||||
# define RFILE ".rnd"
|
||||
# define LIST_SEPARATOR_CHAR ';'
|
||||
# define EXIT(n) { if (n) printf("ERROR: %d\n", (int)n); exit(n); }
|
||||
|
||||
# else
|
||||
/* !defined VMS */
|
||||
# ifdef OPENSSL_SYS_MPE
|
||||
# define NO_SYS_PARAM_H
|
||||
# endif
|
||||
# ifdef OPENSSL_UNISTD
|
||||
# include OPENSSL_UNISTD
|
||||
# else
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
# ifndef NO_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# if defined(NeXT) || defined(OPENSSL_SYS_NEWS4)
|
||||
# define pid_t int /* pid_t is missing on NEXTSTEP/OPENSTEP
|
||||
* (unless when compiling with -D_POSIX_SOURCE,
|
||||
* which doesn't work for us) */
|
||||
# endif
|
||||
# if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) || defined(OPENSSL_SYS_SUNOS)
|
||||
# define ssize_t int /* ditto */
|
||||
# endif
|
||||
# ifdef OPENSSL_SYS_NEWS4 /* setvbuf is missing on mips-sony-bsd */
|
||||
# define setvbuf(a, b, c, d) setbuffer((a), (b), (d))
|
||||
typedef unsigned long clock_t;
|
||||
# endif
|
||||
|
||||
# define OPENSSL_CONF "openssl.cnf"
|
||||
# define SSLEAY_CONF OPENSSL_CONF
|
||||
# define RFILE ".rnd"
|
||||
# define LIST_SEPARATOR_CHAR ':'
|
||||
# define NUL_DEV "/dev/null"
|
||||
# define EXIT(n) exit(n)
|
||||
# endif
|
||||
|
||||
# define SSLeay_getpid() getpid()
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*************/
|
||||
|
||||
#ifdef USE_SOCKETS
|
||||
# if defined(WINDOWS) || defined(MSDOS)
|
||||
/* windows world */
|
||||
|
||||
# ifdef OPENSSL_NO_SOCK
|
||||
# define SSLeay_Write(a,b,c) (-1)
|
||||
# define SSLeay_Read(a,b,c) (-1)
|
||||
# define SHUTDOWN(fd) close(fd)
|
||||
# define SHUTDOWN2(fd) close(fd)
|
||||
# elif !defined(__DJGPP__)
|
||||
# include <winsock.h>
|
||||
extern HINSTANCE _hInstance;
|
||||
# ifdef _WIN64
|
||||
/*
|
||||
* Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
|
||||
* the value constitutes an index in per-process table of limited size
|
||||
* and not a real pointer.
|
||||
*/
|
||||
# define socket(d,t,p) ((int)socket(d,t,p))
|
||||
# define accept(s,f,l) ((int)accept(s,f,l))
|
||||
# endif
|
||||
# define SSLeay_Write(a,b,c) send((a),(b),(c),0)
|
||||
# define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
|
||||
# define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }
|
||||
# define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
|
||||
# else
|
||||
# define SSLeay_Write(a,b,c) write_s(a,b,c,0)
|
||||
# define SSLeay_Read(a,b,c) read_s(a,b,c)
|
||||
# define SHUTDOWN(fd) close_s(fd)
|
||||
# define SHUTDOWN2(fd) close_s(fd)
|
||||
# endif
|
||||
|
||||
# elif defined(MAC_OS_pre_X)
|
||||
|
||||
# include "MacSocket.h"
|
||||
# define SSLeay_Write(a,b,c) MacSocket_send((a),(b),(c))
|
||||
# define SSLeay_Read(a,b,c) MacSocket_recv((a),(b),(c),true)
|
||||
# define SHUTDOWN(fd) MacSocket_close(fd)
|
||||
# define SHUTDOWN2(fd) MacSocket_close(fd)
|
||||
|
||||
# elif defined(OPENSSL_SYS_NETWARE)
|
||||
/* NetWare uses the WinSock2 interfaces by default, but can be configured for BSD
|
||||
*/
|
||||
# if defined(NETWARE_BSDSOCK)
|
||||
# include <sys/socket.h>
|
||||
# include <netinet/in.h>
|
||||
# include <sys/time.h>
|
||||
# include <sys/select.h>
|
||||
# define INVALID_SOCKET (int)(~0)
|
||||
# else
|
||||
# include <novsock2.h>
|
||||
# endif
|
||||
# define SSLeay_Write(a,b,c) send((a),(b),(c),0)
|
||||
# define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
|
||||
# define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }
|
||||
# define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
|
||||
|
||||
# else
|
||||
|
||||
# ifndef NO_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
# endif
|
||||
# ifdef OPENSSL_SYS_VXWORKS
|
||||
# include <time.h>
|
||||
# elif !defined(OPENSSL_SYS_MPE)
|
||||
# include <sys/time.h> /* Needed under linux for FD_XXX */
|
||||
# endif
|
||||
|
||||
# include <netdb.h>
|
||||
# if defined(OPENSSL_SYS_VMS_NODECC)
|
||||
# include <socket.h>
|
||||
# include <in.h>
|
||||
# include <inet.h>
|
||||
# else
|
||||
# include <sys/socket.h>
|
||||
# ifdef FILIO_H
|
||||
# include <sys/filio.h> /* Added for FIONBIO under unixware */
|
||||
# endif
|
||||
# include <netinet/in.h>
|
||||
# include <arpa/inet.h>
|
||||
# endif
|
||||
|
||||
# if defined(NeXT) || defined(_NEXT_SOURCE)
|
||||
# include <sys/fcntl.h>
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
|
||||
# ifdef OPENSSL_SYS_AIX
|
||||
# include <sys/select.h>
|
||||
# endif
|
||||
|
||||
# ifdef __QNX__
|
||||
# include <sys/select.h>
|
||||
# endif
|
||||
|
||||
# if defined(sun)
|
||||
# include <sys/filio.h>
|
||||
# else
|
||||
# ifndef VMS
|
||||
# include <sys/ioctl.h>
|
||||
# else
|
||||
/* ioctl is only in VMS > 7.0 and when socketshr is not used */
|
||||
# if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
|
||||
# include <sys/ioctl.h>
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifdef VMS
|
||||
# include <unixio.h>
|
||||
# if defined(TCPIP_TYPE_SOCKETSHR)
|
||||
# include <socketshr.h>
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# define SSLeay_Read(a,b,c) read((a),(b),(c))
|
||||
# define SSLeay_Write(a,b,c) write((a),(b),(c))
|
||||
# define SHUTDOWN(fd) { shutdown((fd),0); closesocket((fd)); }
|
||||
# define SHUTDOWN2(fd) { shutdown((fd),2); closesocket((fd)); }
|
||||
# ifndef INVALID_SOCKET
|
||||
# define INVALID_SOCKET (-1)
|
||||
# endif /* INVALID_SOCKET */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__ultrix)
|
||||
# ifndef ssize_t
|
||||
# define ssize_t int
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(sun) && !defined(__svr4__) && !defined(__SVR4)
|
||||
/* include headers first, so our defines don't break it */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
/* bcopy can handle overlapping moves according to SunOS 4.1.4 manpage */
|
||||
# define memmove(s1,s2,n) bcopy((s2),(s1),(n))
|
||||
# define strtoul(s,e,b) ((unsigned long int)strtol((s),(e),(b)))
|
||||
extern char *sys_errlist[]; extern int sys_nerr;
|
||||
# define strerror(errnum) \
|
||||
(((errnum)<0 || (errnum)>=sys_nerr) ? NULL : sys_errlist[errnum])
|
||||
/* Being signed SunOS 4.x memcpy breaks ASN1_OBJECT table lookup */
|
||||
#include "crypto/o_str.h"
|
||||
# define memcmp OPENSSL_memcmp
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_EXIT
|
||||
# if defined(MONOLITH) && !defined(OPENSSL_C)
|
||||
# define OPENSSL_EXIT(n) return(n)
|
||||
# else
|
||||
# define OPENSSL_EXIT(n) do { EXIT(n); return(n); } while(0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/***********************************************/
|
||||
|
||||
/* do we need to do this for getenv.
|
||||
* Just define getenv for use under windows */
|
||||
|
||||
#ifdef WIN16
|
||||
/* How to do this needs to be thought out a bit more.... */
|
||||
/*char *GETENV(char *);
|
||||
#define Getenv GETENV*/
|
||||
#define Getenv getenv
|
||||
#else
|
||||
#define Getenv getenv
|
||||
#endif
|
||||
|
||||
#define DG_GCC_BUG /* gcc < 2.6.3 on DGUX */
|
||||
|
||||
#ifdef sgi
|
||||
#define IRIX_CC_BUG /* all version of IRIX I've tested (4.* 5.*) */
|
||||
#endif
|
||||
#ifdef OPENSSL_SYS_SNI
|
||||
#define IRIX_CC_BUG /* CDS++ up to V2.0Bsomething suffered from the same bug.*/
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_SYS_WINDOWS)
|
||||
# define strcasecmp _stricmp
|
||||
# define strncasecmp _strnicmp
|
||||
#elif defined(OPENSSL_SYS_VMS)
|
||||
/* VMS below version 7.0 doesn't have strcasecmp() */
|
||||
# include "o_str.h"
|
||||
# define strcasecmp OPENSSL_strcasecmp
|
||||
# define strncasecmp OPENSSL_strncasecmp
|
||||
# define OPENSSL_IMPLEMENTS_strncasecmp
|
||||
#elif defined(OPENSSL_SYS_OS2) && defined(__EMX__)
|
||||
# define strcasecmp stricmp
|
||||
# define strncasecmp strnicmp
|
||||
#elif defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB)
|
||||
# define strcasecmp stricmp
|
||||
# define strncasecmp strnicmp
|
||||
#else
|
||||
# ifdef NO_STRINGS_H
|
||||
int strcasecmp();
|
||||
int strncasecmp();
|
||||
# else
|
||||
/*Begin: 17Aug2006, Chris */
|
||||
#ifndef RSDK_BUILT
|
||||
# include <strings.h>
|
||||
#endif
|
||||
/*End: 17Aug2006, Chris */
|
||||
# endif /* NO_STRINGS_H */
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_SYS_OS2) && defined(__EMX__)
|
||||
# include <io.h>
|
||||
# include <fcntl.h>
|
||||
# define NO_SYSLOG
|
||||
#endif
|
||||
|
||||
/* vxworks */
|
||||
#if defined(OPENSSL_SYS_VXWORKS)
|
||||
#include <ioLib.h>
|
||||
#include <tickLib.h>
|
||||
#include <sysLib.h>
|
||||
|
||||
#define TTY_STRUCT int
|
||||
|
||||
#define sleep(a) taskDelay((a) * sysClkRateGet())
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <sockLib.h>
|
||||
#include <taskLib.h>
|
||||
|
||||
#define getpid taskIdSelf
|
||||
|
||||
/* NOTE: these are implemented by helpers in database app!
|
||||
* if the database is not linked, we need to implement them
|
||||
* elswhere */
|
||||
struct hostent *gethostbyname(const char *name);
|
||||
struct hostent *gethostbyaddr(const char *addr, int length, int type);
|
||||
struct servent *getservbyname(const char *name, const char *proto);
|
||||
|
||||
#endif
|
||||
/* end vxworks */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
285
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/e_os2.h
Executable file
285
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/e_os2.h
Executable file
@ -0,0 +1,285 @@
|
||||
/* e_os2.h */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2000 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).
|
||||
*
|
||||
*/
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#include <openssl/opensslconf.h>
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
#ifndef HEADER_E_OS2_H
|
||||
#define HEADER_E_OS2_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Detect operating systems. This probably needs completing.
|
||||
* The result is that at least one OPENSSL_SYS_os macro should be defined.
|
||||
* However, if none is defined, Unix is assumed.
|
||||
**/
|
||||
#ifdef RSDK_BUILT
|
||||
#define OPENSSL_SYS_UNIX
|
||||
#else
|
||||
#define OPENSSL_SYS_WIN32
|
||||
#endif
|
||||
/* ----------------------- Macintosh, before MacOS X ----------------------- */
|
||||
#if defined(__MWERKS__) && defined(macintosh) || defined(OPENSSL_SYSNAME_MAC)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_MACINTOSH_CLASSIC
|
||||
#endif
|
||||
|
||||
/* ----------------------- NetWare ----------------------------------------- */
|
||||
#if defined(NETWARE) || defined(OPENSSL_SYSNAME_NETWARE)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_NETWARE
|
||||
#endif
|
||||
|
||||
/* ---------------------- Microsoft operating systems ---------------------- */
|
||||
|
||||
/* Note that MSDOS actually denotes 32-bit environments running on top of
|
||||
MS-DOS, such as DJGPP one. */
|
||||
#if defined(OPENSSL_SYSNAME_MSDOS)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_MSDOS
|
||||
#endif
|
||||
|
||||
/* For 32 bit environment, there seems to be the CygWin environment and then
|
||||
all the others that try to do the same thing Microsoft does... */
|
||||
#if defined(OPENSSL_SYSNAME_UWIN)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_WIN32_UWIN
|
||||
#else
|
||||
# if defined(__CYGWIN32__) || defined(OPENSSL_SYSNAME_CYGWIN32)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_WIN32_CYGWIN
|
||||
# else
|
||||
# if defined(_WIN32) || defined(OPENSSL_SYSNAME_WIN32)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_WIN32
|
||||
# endif
|
||||
# if defined(OPENSSL_SYSNAME_WINNT)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_WINNT
|
||||
# endif
|
||||
# if defined(OPENSSL_SYSNAME_WINCE)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_WINCE
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Anything that tries to look like Microsoft is "Windows" */
|
||||
#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_WINDOWS
|
||||
# ifndef OPENSSL_SYS_MSDOS
|
||||
# define OPENSSL_SYS_MSDOS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* DLL settings. This part is a bit tough, because it's up to the application
|
||||
implementor how he or she will link the application, so it requires some
|
||||
macro to be used. */
|
||||
#ifdef OPENSSL_SYS_WINDOWS
|
||||
# ifndef OPENSSL_OPT_WINDLL
|
||||
# if defined(_WINDLL) /* This is used when building OpenSSL to indicate that
|
||||
DLL linkage should be used */
|
||||
# define OPENSSL_OPT_WINDLL
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* -------------------------------- OpenVMS -------------------------------- */
|
||||
#if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYSNAME_VMS)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_VMS
|
||||
# if defined(__DECC)
|
||||
# define OPENSSL_SYS_VMS_DECC
|
||||
# elif defined(__DECCXX)
|
||||
# define OPENSSL_SYS_VMS_DECC
|
||||
# define OPENSSL_SYS_VMS_DECCXX
|
||||
# else
|
||||
# define OPENSSL_SYS_VMS_NODECC
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* --------------------------------- OS/2 ---------------------------------- */
|
||||
#if defined(__EMX__) || defined(__OS2__)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_OS2
|
||||
#endif
|
||||
|
||||
/* --------------------------------- Unix ---------------------------------- */
|
||||
#ifdef OPENSSL_SYS_UNIX
|
||||
# if defined(linux) || defined(__linux__) || defined(OPENSSL_SYSNAME_LINUX)
|
||||
# define OPENSSL_SYS_LINUX
|
||||
# endif
|
||||
# ifdef OPENSSL_SYSNAME_MPE
|
||||
# define OPENSSL_SYS_MPE
|
||||
# endif
|
||||
# ifdef OPENSSL_SYSNAME_SNI
|
||||
# define OPENSSL_SYS_SNI
|
||||
# endif
|
||||
# ifdef OPENSSL_SYSNAME_ULTRASPARC
|
||||
# define OPENSSL_SYS_ULTRASPARC
|
||||
# endif
|
||||
# ifdef OPENSSL_SYSNAME_NEWS4
|
||||
# define OPENSSL_SYS_NEWS4
|
||||
# endif
|
||||
# ifdef OPENSSL_SYSNAME_MACOSX
|
||||
# define OPENSSL_SYS_MACOSX
|
||||
# endif
|
||||
# ifdef OPENSSL_SYSNAME_MACOSX_RHAPSODY
|
||||
# define OPENSSL_SYS_MACOSX_RHAPSODY
|
||||
# define OPENSSL_SYS_MACOSX
|
||||
# endif
|
||||
# ifdef OPENSSL_SYSNAME_SUNOS
|
||||
# define OPENSSL_SYS_SUNOS
|
||||
#endif
|
||||
# if defined(_CRAY) || defined(OPENSSL_SYSNAME_CRAY)
|
||||
# define OPENSSL_SYS_CRAY
|
||||
# endif
|
||||
# if defined(_AIX) || defined(OPENSSL_SYSNAME_AIX)
|
||||
# define OPENSSL_SYS_AIX
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* --------------------------------- VOS ----------------------------------- */
|
||||
#ifdef OPENSSL_SYSNAME_VOS
|
||||
# define OPENSSL_SYS_VOS
|
||||
#endif
|
||||
|
||||
/* ------------------------------- VxWorks --------------------------------- */
|
||||
#ifdef OPENSSL_SYSNAME_VXWORKS
|
||||
# define OPENSSL_SYS_VXWORKS
|
||||
#endif
|
||||
|
||||
/**
|
||||
* That's it for OS-specific stuff
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
/* Specials for I/O an exit */
|
||||
#ifdef OPENSSL_SYS_MSDOS
|
||||
# define OPENSSL_UNISTD_IO <io.h>
|
||||
# define OPENSSL_DECLARE_EXIT extern void exit(int);
|
||||
#else
|
||||
# define OPENSSL_UNISTD_IO OPENSSL_UNISTD
|
||||
# define OPENSSL_DECLARE_EXIT /* declared in unistd.h */
|
||||
#endif
|
||||
|
||||
/* Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare
|
||||
certain global symbols that, with some compilers under VMS, have to be
|
||||
defined and declared explicitely with globaldef and globalref.
|
||||
Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare
|
||||
DLL exports and imports for compilers under Win32. These are a little
|
||||
more complicated to use. Basically, for any library that exports some
|
||||
global variables, the following code must be present in the header file
|
||||
that declares them, before OPENSSL_EXTERN is used:
|
||||
|
||||
#ifdef SOME_BUILD_FLAG_MACRO
|
||||
# undef OPENSSL_EXTERN
|
||||
# define OPENSSL_EXTERN OPENSSL_EXPORT
|
||||
#endif
|
||||
|
||||
The default is to have OPENSSL_EXPORT, OPENSSL_IMPORT and OPENSSL_GLOBAL
|
||||
have some generally sensible values, and for OPENSSL_EXTERN to have the
|
||||
value OPENSSL_IMPORT.
|
||||
*/
|
||||
|
||||
#if defined(OPENSSL_SYS_VMS_NODECC)
|
||||
# define OPENSSL_EXPORT globalref
|
||||
# define OPENSSL_IMPORT globalref
|
||||
# define OPENSSL_GLOBAL globaldef
|
||||
#elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL)
|
||||
# define OPENSSL_EXPORT extern __declspec(dllexport)
|
||||
# define OPENSSL_IMPORT extern __declspec(dllimport)
|
||||
# define OPENSSL_GLOBAL
|
||||
#else
|
||||
# define OPENSSL_EXPORT extern
|
||||
# define OPENSSL_IMPORT extern
|
||||
# define OPENSSL_GLOBAL
|
||||
#endif
|
||||
#define OPENSSL_EXTERN OPENSSL_IMPORT
|
||||
|
||||
/* Macros to allow global variables to be reached through function calls when
|
||||
required (if a shared library version requvres it, for example.
|
||||
The way it's done allows definitions like this:
|
||||
|
||||
// in foobar.c
|
||||
OPENSSL_IMPLEMENT_GLOBAL(int,foobar) = 0;
|
||||
// in foobar.h
|
||||
OPENSSL_DECLARE_GLOBAL(int,foobar);
|
||||
#define foobar OPENSSL_GLOBAL_REF(foobar)
|
||||
*/
|
||||
#ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||
# define OPENSSL_IMPLEMENT_GLOBAL(type,name) \
|
||||
extern type _hide_##name; \
|
||||
type *_shadow_##name(void) { return &_hide_##name; } \
|
||||
static type _hide_##name
|
||||
# define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void)
|
||||
# define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name()))
|
||||
#else
|
||||
# define OPENSSL_IMPLEMENT_GLOBAL(type,name) OPENSSL_GLOBAL type _shadow_##name
|
||||
# define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name
|
||||
# define OPENSSL_GLOBAL_REF(name) _shadow_##name
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
302
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/err.h
Executable file
302
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/err.h
Executable file
@ -0,0 +1,302 @@
|
||||
/* crypto/err/err.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_ERR_H
|
||||
#define HEADER_ERR_H
|
||||
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_BIO
|
||||
#include <openssl/bio.h>
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_LHASH
|
||||
#include <openssl/lhash.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e)
|
||||
#else
|
||||
#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0)
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#define ERR_TXT_MALLOCED 0x01
|
||||
#define ERR_TXT_STRING 0x02
|
||||
|
||||
#define ERR_NUM_ERRORS 16
|
||||
typedef struct err_state_st
|
||||
{
|
||||
unsigned long pid;
|
||||
unsigned long err_buffer[ERR_NUM_ERRORS];
|
||||
char *err_data[ERR_NUM_ERRORS];
|
||||
int err_data_flags[ERR_NUM_ERRORS];
|
||||
const char *err_file[ERR_NUM_ERRORS];
|
||||
int err_line[ERR_NUM_ERRORS];
|
||||
int top,bottom;
|
||||
} ERR_STATE;
|
||||
|
||||
/* library */
|
||||
#define ERR_LIB_NONE 1
|
||||
#define ERR_LIB_SYS 2
|
||||
#define ERR_LIB_BN 3
|
||||
#define ERR_LIB_RSA 4
|
||||
#define ERR_LIB_DH 5
|
||||
#define ERR_LIB_EVP 6
|
||||
#define ERR_LIB_BUF 7
|
||||
#define ERR_LIB_OBJ 8
|
||||
#define ERR_LIB_PEM 9
|
||||
#define ERR_LIB_DSA 10
|
||||
#define ERR_LIB_X509 11
|
||||
/* #define ERR_LIB_METH 12 */
|
||||
#define ERR_LIB_ASN1 13
|
||||
#define ERR_LIB_CONF 14
|
||||
#define ERR_LIB_CRYPTO 15
|
||||
#define ERR_LIB_EC 16
|
||||
#define ERR_LIB_SSL 20
|
||||
/* #define ERR_LIB_SSL23 21 */
|
||||
/* #define ERR_LIB_SSL2 22 */
|
||||
/* #define ERR_LIB_SSL3 23 */
|
||||
/* #define ERR_LIB_RSAREF 30 */
|
||||
/* #define ERR_LIB_PROXY 31 */
|
||||
#define ERR_LIB_BIO 32
|
||||
#define ERR_LIB_PKCS7 33
|
||||
#define ERR_LIB_X509V3 34
|
||||
#define ERR_LIB_PKCS12 35
|
||||
#define ERR_LIB_RAND 36
|
||||
#define ERR_LIB_DSO 37
|
||||
#define ERR_LIB_ENGINE 38
|
||||
#define ERR_LIB_OCSP 39
|
||||
#define ERR_LIB_UI 40
|
||||
#define ERR_LIB_COMP 41
|
||||
#define ERR_LIB_FIPS 42
|
||||
|
||||
#define ERR_LIB_USER 128
|
||||
|
||||
#define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__)
|
||||
#define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__)
|
||||
#define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__)
|
||||
#define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__)
|
||||
#define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__)
|
||||
#define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__)
|
||||
#define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__)
|
||||
#define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__)
|
||||
#define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__)
|
||||
#define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__)
|
||||
#define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__)
|
||||
#define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__)
|
||||
#define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__)
|
||||
#define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__)
|
||||
#define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__)
|
||||
#define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__)
|
||||
#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__)
|
||||
#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__)
|
||||
#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__)
|
||||
#define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__)
|
||||
#define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__)
|
||||
#define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__)
|
||||
#define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__)
|
||||
#define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__)
|
||||
#define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__)
|
||||
#define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),__FILE__,__LINE__)
|
||||
|
||||
/* Borland C seems too stupid to be able to shift and do longs in
|
||||
* the pre-processor :-( */
|
||||
#define ERR_PACK(l,f,r) (((((unsigned long)l)&0xffL)*0x1000000)| \
|
||||
((((unsigned long)f)&0xfffL)*0x1000)| \
|
||||
((((unsigned long)r)&0xfffL)))
|
||||
#define ERR_GET_LIB(l) (int)((((unsigned long)l)>>24L)&0xffL)
|
||||
#define ERR_GET_FUNC(l) (int)((((unsigned long)l)>>12L)&0xfffL)
|
||||
#define ERR_GET_REASON(l) (int)((l)&0xfffL)
|
||||
#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL)
|
||||
|
||||
|
||||
/* OS functions */
|
||||
#define SYS_F_FOPEN 1
|
||||
#define SYS_F_CONNECT 2
|
||||
#define SYS_F_GETSERVBYNAME 3
|
||||
#define SYS_F_SOCKET 4
|
||||
#define SYS_F_IOCTLSOCKET 5
|
||||
#define SYS_F_BIND 6
|
||||
#define SYS_F_LISTEN 7
|
||||
#define SYS_F_ACCEPT 8
|
||||
#define SYS_F_WSASTARTUP 9 /* Winsock stuff */
|
||||
#define SYS_F_OPENDIR 10
|
||||
#define SYS_F_FREAD 11
|
||||
#define SYS_F_GETADDRINFO 12
|
||||
|
||||
|
||||
/* reasons */
|
||||
#define ERR_R_SYS_LIB ERR_LIB_SYS /* 2 */
|
||||
#define ERR_R_BN_LIB ERR_LIB_BN /* 3 */
|
||||
#define ERR_R_RSA_LIB ERR_LIB_RSA /* 4 */
|
||||
#define ERR_R_DH_LIB ERR_LIB_DH /* 5 */
|
||||
#define ERR_R_EVP_LIB ERR_LIB_EVP /* 6 */
|
||||
#define ERR_R_BUF_LIB ERR_LIB_BUF /* 7 */
|
||||
#define ERR_R_OBJ_LIB ERR_LIB_OBJ /* 8 */
|
||||
#define ERR_R_PEM_LIB ERR_LIB_PEM /* 9 */
|
||||
#define ERR_R_DSA_LIB ERR_LIB_DSA /* 10 */
|
||||
#define ERR_R_X509_LIB ERR_LIB_X509 /* 11 */
|
||||
#define ERR_R_ASN1_LIB ERR_LIB_ASN1 /* 13 */
|
||||
#define ERR_R_CONF_LIB ERR_LIB_CONF /* 14 */
|
||||
#define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO /* 15 */
|
||||
#define ERR_R_EC_LIB ERR_LIB_EC /* 16 */
|
||||
#define ERR_R_SSL_LIB ERR_LIB_SSL /* 20 */
|
||||
#define ERR_R_BIO_LIB ERR_LIB_BIO /* 32 */
|
||||
#define ERR_R_PKCS7_LIB ERR_LIB_PKCS7 /* 33 */
|
||||
#define ERR_R_X509V3_LIB ERR_LIB_X509V3 /* 34 */
|
||||
#define ERR_R_PKCS12_LIB ERR_LIB_PKCS12 /* 35 */
|
||||
#define ERR_R_RAND_LIB ERR_LIB_RAND /* 36 */
|
||||
#define ERR_R_DSO_LIB ERR_LIB_DSO /* 37 */
|
||||
#define ERR_R_ENGINE_LIB ERR_LIB_ENGINE /* 38 */
|
||||
#define ERR_R_OCSP_LIB ERR_LIB_OCSP /* 39 */
|
||||
#define ERR_R_UI_LIB ERR_LIB_UI /* 40 */
|
||||
#define ERR_R_COMP_LIB ERR_LIB_COMP /* 41 */
|
||||
|
||||
#define ERR_R_NESTED_ASN1_ERROR 58
|
||||
#define ERR_R_BAD_ASN1_OBJECT_HEADER 59
|
||||
#define ERR_R_BAD_GET_ASN1_OBJECT_CALL 60
|
||||
#define ERR_R_EXPECTING_AN_ASN1_SEQUENCE 61
|
||||
#define ERR_R_ASN1_LENGTH_MISMATCH 62
|
||||
#define ERR_R_MISSING_ASN1_EOS 63
|
||||
|
||||
/* fatal error */
|
||||
#define ERR_R_FATAL 64
|
||||
#define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL)
|
||||
#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL)
|
||||
#define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL)
|
||||
#define ERR_R_INTERNAL_ERROR (4|ERR_R_FATAL)
|
||||
|
||||
/* 99 is the maximum possible ERR_R_... code, higher values
|
||||
* are reserved for the individual libraries */
|
||||
|
||||
|
||||
typedef struct ERR_string_data_st
|
||||
{
|
||||
unsigned long error;
|
||||
const char *string;
|
||||
} ERR_STRING_DATA;
|
||||
|
||||
void ERR_put_error(int lib, int func,int reason,const char *file,int line);
|
||||
void ERR_set_error_data(char *data,int flags);
|
||||
|
||||
unsigned long ERR_get_error(void);
|
||||
unsigned long ERR_get_error_line(const char **file,int *line);
|
||||
unsigned long ERR_get_error_line_data(const char **file,int *line,
|
||||
const char **data, int *flags);
|
||||
unsigned long ERR_peek_error(void);
|
||||
unsigned long ERR_peek_error_line(const char **file,int *line);
|
||||
unsigned long ERR_peek_error_line_data(const char **file,int *line,
|
||||
const char **data,int *flags);
|
||||
unsigned long ERR_peek_last_error(void);
|
||||
unsigned long ERR_peek_last_error_line(const char **file,int *line);
|
||||
unsigned long ERR_peek_last_error_line_data(const char **file,int *line,
|
||||
const char **data,int *flags);
|
||||
void ERR_clear_error(void );
|
||||
char *ERR_error_string(unsigned long e,char *buf);
|
||||
void ERR_error_string_n(unsigned long e, char *buf, size_t len);
|
||||
const char *ERR_lib_error_string(unsigned long e);
|
||||
const char *ERR_func_error_string(unsigned long e);
|
||||
const char *ERR_reason_error_string(unsigned long e);
|
||||
void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
|
||||
void *u);
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
void ERR_print_errors_fp(FILE *fp);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_BIO
|
||||
void ERR_print_errors(BIO *bp);
|
||||
void ERR_add_error_data(int num, ...);
|
||||
#endif
|
||||
void ERR_load_strings(int lib,ERR_STRING_DATA str[]);
|
||||
void ERR_unload_strings(int lib,ERR_STRING_DATA str[]);
|
||||
void ERR_load_ERR_strings(void);
|
||||
void ERR_load_crypto_strings(void);
|
||||
void ERR_free_strings(void);
|
||||
|
||||
void ERR_remove_state(unsigned long pid); /* if zero we look it up */
|
||||
ERR_STATE *ERR_get_state(void);
|
||||
|
||||
#ifndef OPENSSL_NO_LHASH
|
||||
LHASH *ERR_get_string_table(void);
|
||||
LHASH *ERR_get_err_state_table(void);
|
||||
void ERR_release_err_state_table(LHASH **hash);
|
||||
#endif
|
||||
|
||||
int ERR_get_next_error_library(void);
|
||||
|
||||
/* This opaque type encapsulates the low-level error-state functions */
|
||||
typedef struct st_ERR_FNS ERR_FNS;
|
||||
/* An application can use this function and provide the return value to loaded
|
||||
* modules that should use the application's ERR state/functionality */
|
||||
const ERR_FNS *ERR_get_implementation(void);
|
||||
/* A loaded module should call this function prior to any ERR operations using
|
||||
* the application's "ERR_FNS". */
|
||||
int ERR_set_implementation(const ERR_FNS *fns);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
985
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/evp.h
Executable file
985
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/evp.h
Executable file
@ -0,0 +1,985 @@
|
||||
/* crypto/evp/evp.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_ENVELOPE_H
|
||||
#define HEADER_ENVELOPE_H
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#ifdef OPENSSL_ALGORITHM_DEFINES
|
||||
# include <openssl/opensslconf.h>
|
||||
#else
|
||||
# define OPENSSL_ALGORITHM_DEFINES
|
||||
# include <openssl/opensslconf.h>
|
||||
# undef OPENSSL_ALGORITHM_DEFINES
|
||||
#endif
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
#include <openssl/ossl_typ.h>
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#include <openssl/symhacks.h>
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
#ifndef OPENSSL_NO_BIO
|
||||
#include <openssl/bio.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
#define EVP_RC2_KEY_SIZE 16
|
||||
#define EVP_RC4_KEY_SIZE 16
|
||||
#define EVP_BLOWFISH_KEY_SIZE 16
|
||||
#define EVP_CAST5_KEY_SIZE 16
|
||||
#define EVP_RC5_32_12_16_KEY_SIZE 16
|
||||
*/
|
||||
#define EVP_MAX_MD_SIZE 64 /* longest known is SHA512 */
|
||||
#define EVP_MAX_KEY_LENGTH 32
|
||||
#define EVP_MAX_IV_LENGTH 16
|
||||
#define EVP_MAX_BLOCK_LENGTH 32
|
||||
|
||||
#define PKCS5_SALT_LEN 8
|
||||
/* Default PKCS#5 iteration count */
|
||||
#define PKCS5_DEFAULT_ITER 2048
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#include <openssl/objects.h>
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
#define EVP_PK_RSA 0x0001
|
||||
#define EVP_PK_DSA 0x0002
|
||||
#define EVP_PK_DH 0x0004
|
||||
#define EVP_PK_EC 0x0008
|
||||
#define EVP_PKT_SIGN 0x0010
|
||||
#define EVP_PKT_ENC 0x0020
|
||||
#define EVP_PKT_EXCH 0x0040
|
||||
#define EVP_PKS_RSA 0x0100
|
||||
#define EVP_PKS_DSA 0x0200
|
||||
#define EVP_PKS_EC 0x0400
|
||||
#define EVP_PKT_EXP 0x1000 /* <= 512 bit key */
|
||||
|
||||
#define EVP_PKEY_NONE NID_undef
|
||||
#define EVP_PKEY_RSA NID_rsaEncryption
|
||||
#define EVP_PKEY_RSA2 NID_rsa
|
||||
#define EVP_PKEY_DSA NID_dsa
|
||||
#define EVP_PKEY_DSA1 NID_dsa_2
|
||||
#define EVP_PKEY_DSA2 NID_dsaWithSHA
|
||||
#define EVP_PKEY_DSA3 NID_dsaWithSHA1
|
||||
#define EVP_PKEY_DSA4 NID_dsaWithSHA1_2
|
||||
#define EVP_PKEY_DH NID_dhKeyAgreement
|
||||
#define EVP_PKEY_EC NID_X9_62_id_ecPublicKey
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
/* Type needs to be a bit field
|
||||
* Sub-type needs to be for variations on the method, as in, can it do
|
||||
* arbitrary encryption.... */
|
||||
struct evp_pkey_st
|
||||
{
|
||||
int type;
|
||||
int save_type;
|
||||
int references;
|
||||
union {
|
||||
char *ptr;
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
struct rsa_st *rsa; /* RSA */
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
struct dsa_st *dsa; /* DSA */
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DH
|
||||
struct dh_st *dh; /* DH */
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
struct ec_key_st *ec; /* ECC */
|
||||
#endif
|
||||
} pkey;
|
||||
int save_parameters;
|
||||
STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
|
||||
} /* EVP_PKEY */;
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
#define EVP_PKEY_MO_SIGN 0x0001
|
||||
#define EVP_PKEY_MO_VERIFY 0x0002
|
||||
#define EVP_PKEY_MO_ENCRYPT 0x0004
|
||||
#define EVP_PKEY_MO_DECRYPT 0x0008
|
||||
|
||||
#if 0
|
||||
/* This structure is required to tie the message digest and signing together.
|
||||
* The lookup can be done by md/pkey_method, oid, oid/pkey_method, or
|
||||
* oid, md and pkey.
|
||||
* This is required because for various smart-card perform the digest and
|
||||
* signing/verification on-board. To handle this case, the specific
|
||||
* EVP_MD and EVP_PKEY_METHODs need to be closely associated.
|
||||
* When a PKEY is created, it will have a EVP_PKEY_METHOD associated with it.
|
||||
* This can either be software or a token to provide the required low level
|
||||
* routines.
|
||||
*/
|
||||
typedef struct evp_pkey_md_st
|
||||
{
|
||||
int oid;
|
||||
EVP_MD *md;
|
||||
EVP_PKEY_METHOD *pkey;
|
||||
} EVP_PKEY_MD;
|
||||
|
||||
#define EVP_rsa_md2() \
|
||||
EVP_PKEY_MD_add(NID_md2WithRSAEncryption,\
|
||||
EVP_rsa_pkcs1(),EVP_md2())
|
||||
#define EVP_rsa_md5() \
|
||||
EVP_PKEY_MD_add(NID_md5WithRSAEncryption,\
|
||||
EVP_rsa_pkcs1(),EVP_md5())
|
||||
#define EVP_rsa_sha0() \
|
||||
EVP_PKEY_MD_add(NID_shaWithRSAEncryption,\
|
||||
EVP_rsa_pkcs1(),EVP_sha())
|
||||
#define EVP_rsa_sha1() \
|
||||
EVP_PKEY_MD_add(NID_sha1WithRSAEncryption,\
|
||||
EVP_rsa_pkcs1(),EVP_sha1())
|
||||
#define EVP_rsa_ripemd160() \
|
||||
EVP_PKEY_MD_add(NID_ripemd160WithRSA,\
|
||||
EVP_rsa_pkcs1(),EVP_ripemd160())
|
||||
#define EVP_rsa_mdc2() \
|
||||
EVP_PKEY_MD_add(NID_mdc2WithRSA,\
|
||||
EVP_rsa_octet_string(),EVP_mdc2())
|
||||
#define EVP_dsa_sha() \
|
||||
EVP_PKEY_MD_add(NID_dsaWithSHA,\
|
||||
EVP_dsa(),EVP_sha())
|
||||
#define EVP_dsa_sha1() \
|
||||
EVP_PKEY_MD_add(NID_dsaWithSHA1,\
|
||||
EVP_dsa(),EVP_sha1())
|
||||
|
||||
typedef struct evp_pkey_method_st
|
||||
{
|
||||
char *name;
|
||||
int flags;
|
||||
int type; /* RSA, DSA, an SSLeay specific constant */
|
||||
int oid; /* For the pub-key type */
|
||||
int encrypt_oid; /* pub/priv key encryption */
|
||||
|
||||
int (*sign)();
|
||||
int (*verify)();
|
||||
struct {
|
||||
int (*set)(); /* get and/or set the underlying type */
|
||||
int (*get)();
|
||||
int (*encrypt)();
|
||||
int (*decrypt)();
|
||||
int (*i2d)();
|
||||
int (*d2i)();
|
||||
int (*dup)();
|
||||
} pub,priv;
|
||||
int (*set_asn1_parameters)();
|
||||
int (*get_asn1_parameters)();
|
||||
} EVP_PKEY_METHOD;
|
||||
#endif
|
||||
|
||||
#ifndef EVP_MD
|
||||
struct env_md_st
|
||||
{
|
||||
int type;
|
||||
int pkey_type;
|
||||
int md_size;
|
||||
unsigned int flags;
|
||||
int (*init)(EVP_MD_CTX *ctx);
|
||||
int (*update)(EVP_MD_CTX *ctx,const void *data,size_t count);
|
||||
int (*final)(EVP_MD_CTX *ctx,unsigned char *md);
|
||||
int (*copy)(EVP_MD_CTX *to,const EVP_MD_CTX *from);
|
||||
int (*cleanup)(EVP_MD_CTX *ctx);
|
||||
|
||||
/* FIXME: prototype these some day */
|
||||
int (*sign)(int type, const unsigned char *m, unsigned int m_length,
|
||||
unsigned char *sigret, unsigned int *siglen, void *key);
|
||||
int (*verify)(int type, const unsigned char *m, unsigned int m_length,
|
||||
const unsigned char *sigbuf, unsigned int siglen,
|
||||
void *key);
|
||||
int required_pkey_type[5]; /*EVP_PKEY_xxx */
|
||||
int block_size;
|
||||
int ctx_size; /* how big does the ctx->md_data need to be */
|
||||
} /* EVP_MD */;
|
||||
|
||||
typedef int evp_sign_method(int type,const unsigned char *m,
|
||||
unsigned int m_length,unsigned char *sigret,
|
||||
unsigned int *siglen, void *key);
|
||||
typedef int evp_verify_method(int type,const unsigned char *m,
|
||||
unsigned int m_length,const unsigned char *sigbuf,
|
||||
unsigned int siglen, void *key);
|
||||
|
||||
#define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single
|
||||
* block */
|
||||
|
||||
#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0}
|
||||
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
#define EVP_PKEY_DSA_method (evp_sign_method *)DSA_sign, \
|
||||
(evp_verify_method *)DSA_verify, \
|
||||
{EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \
|
||||
EVP_PKEY_DSA4,0}
|
||||
#else
|
||||
#define EVP_PKEY_DSA_method EVP_PKEY_NULL_method
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_ECDSA
|
||||
#define EVP_PKEY_ECDSA_method (evp_sign_method *)ECDSA_sign, \
|
||||
(evp_verify_method *)ECDSA_verify, \
|
||||
{EVP_PKEY_EC,0,0,0}
|
||||
#else
|
||||
#define EVP_PKEY_ECDSA_method EVP_PKEY_NULL_method
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
#define EVP_PKEY_RSA_method (evp_sign_method *)RSA_sign, \
|
||||
(evp_verify_method *)RSA_verify, \
|
||||
{EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}
|
||||
#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \
|
||||
(evp_sign_method *)RSA_sign_ASN1_OCTET_STRING, \
|
||||
(evp_verify_method *)RSA_verify_ASN1_OCTET_STRING, \
|
||||
{EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}
|
||||
#else
|
||||
#define EVP_PKEY_RSA_method EVP_PKEY_NULL_method
|
||||
#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method EVP_PKEY_NULL_method
|
||||
#endif
|
||||
|
||||
#endif /* !EVP_MD */
|
||||
|
||||
struct env_md_ctx_st
|
||||
{
|
||||
const EVP_MD *digest;
|
||||
ENGINE *engine; /* functional reference if 'digest' is ENGINE-provided */
|
||||
unsigned int flags;
|
||||
void *md_data;
|
||||
} /* EVP_MD_CTX */;
|
||||
|
||||
/* values for EVP_MD_CTX flags */
|
||||
|
||||
#define EVP_MD_CTX_FLAG_ONESHOT 0x0001 /* digest update will be called
|
||||
* once only */
|
||||
#define EVP_MD_CTX_FLAG_CLEANED 0x0002 /* context has already been
|
||||
* cleaned */
|
||||
#define EVP_MD_CTX_FLAG_REUSE 0x0004 /* Don't free up ctx->md_data
|
||||
* in EVP_MD_CTX_cleanup */
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
struct evp_cipher_st
|
||||
{
|
||||
int nid;
|
||||
int block_size;
|
||||
int key_len; /* Default value for variable length ciphers */
|
||||
int iv_len;
|
||||
unsigned long flags; /* Various flags */
|
||||
int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
const unsigned char *iv, int enc); /* init key */
|
||||
int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
const unsigned char *in, unsigned int inl);/* encrypt/decrypt data */
|
||||
int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */
|
||||
int ctx_size; /* how big ctx->cipher_data needs to be */
|
||||
int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */
|
||||
int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */
|
||||
int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); /* Miscellaneous operations */
|
||||
void *app_data; /* Application data */
|
||||
} /* EVP_CIPHER */;
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
/* Values for cipher flags */
|
||||
|
||||
/* Modes for ciphers */
|
||||
|
||||
#define EVP_CIPH_STREAM_CIPHER 0x0
|
||||
#define EVP_CIPH_ECB_MODE 0x1
|
||||
#define EVP_CIPH_CBC_MODE 0x2
|
||||
#define EVP_CIPH_CFB_MODE 0x3
|
||||
#define EVP_CIPH_OFB_MODE 0x4
|
||||
#define EVP_CIPH_MODE 0x7
|
||||
/* Set if variable length cipher */
|
||||
#define EVP_CIPH_VARIABLE_LENGTH 0x8
|
||||
/* Set if the iv handling should be done by the cipher itself */
|
||||
#define EVP_CIPH_CUSTOM_IV 0x10
|
||||
/* Set if the cipher's init() function should be called if key is NULL */
|
||||
#define EVP_CIPH_ALWAYS_CALL_INIT 0x20
|
||||
/* Call ctrl() to init cipher parameters */
|
||||
#define EVP_CIPH_CTRL_INIT 0x40
|
||||
/* Don't use standard key length function */
|
||||
#define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80
|
||||
/* Don't use standard block padding */
|
||||
#define EVP_CIPH_NO_PADDING 0x100
|
||||
/* cipher handles random key generation */
|
||||
#define EVP_CIPH_RAND_KEY 0x200
|
||||
|
||||
/* ctrl() values */
|
||||
|
||||
#define EVP_CTRL_INIT 0x0
|
||||
#define EVP_CTRL_SET_KEY_LENGTH 0x1
|
||||
#define EVP_CTRL_GET_RC2_KEY_BITS 0x2
|
||||
#define EVP_CTRL_SET_RC2_KEY_BITS 0x3
|
||||
#define EVP_CTRL_GET_RC5_ROUNDS 0x4
|
||||
#define EVP_CTRL_SET_RC5_ROUNDS 0x5
|
||||
#define EVP_CTRL_RAND_KEY 0x6
|
||||
|
||||
typedef struct evp_cipher_info_st
|
||||
{
|
||||
const EVP_CIPHER *cipher;
|
||||
unsigned char iv[EVP_MAX_IV_LENGTH];
|
||||
} EVP_CIPHER_INFO;
|
||||
|
||||
struct evp_cipher_ctx_st
|
||||
{
|
||||
const EVP_CIPHER *cipher;
|
||||
ENGINE *engine; /* functional reference if 'cipher' is ENGINE-provided */
|
||||
int encrypt; /* encrypt or decrypt */
|
||||
int buf_len; /* number we have left */
|
||||
|
||||
unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */
|
||||
unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */
|
||||
unsigned char buf[EVP_MAX_BLOCK_LENGTH];/* saved partial block */
|
||||
int num; /* used by cfb/ofb mode */
|
||||
|
||||
void *app_data; /* application stuff */
|
||||
int key_len; /* May change for variable length cipher */
|
||||
unsigned int flags; /* Various flags */
|
||||
void *cipher_data; /* per EVP data */
|
||||
int final_used;
|
||||
int block_mask;
|
||||
unsigned char final[EVP_MAX_BLOCK_LENGTH];/* possible final block */
|
||||
} /* EVP_CIPHER_CTX */;
|
||||
|
||||
typedef struct evp_Encode_Ctx_st
|
||||
{
|
||||
int num; /* number saved in a partial encode/decode */
|
||||
int length; /* The length is either the output line length
|
||||
* (in input bytes) or the shortest input line
|
||||
* length that is ok. Once decoding begins,
|
||||
* the length is adjusted up each time a longer
|
||||
* line is decoded */
|
||||
unsigned char enc_data[80]; /* data to encode */
|
||||
int line_num; /* number read on current line */
|
||||
int expect_nl;
|
||||
} EVP_ENCODE_CTX;
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
/* Password based encryption function */
|
||||
typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
|
||||
ASN1_TYPE *param, const EVP_CIPHER *cipher,
|
||||
const EVP_MD *md, int en_de);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
#define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
|
||||
(char *)(rsa))
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
#define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
|
||||
(char *)(dsa))
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_DH
|
||||
#define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\
|
||||
(char *)(dh))
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_EC
|
||||
#define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\
|
||||
(char *)(eckey))
|
||||
#endif
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
/* Add some extra combinations */
|
||||
#define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
|
||||
#define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))
|
||||
#define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
|
||||
#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
#define EVP_MD_type(e) ((e)->type)
|
||||
#define EVP_MD_nid(e) EVP_MD_type(e)
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e))
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
#define EVP_MD_pkey_type(e) ((e)->pkey_type)
|
||||
#define EVP_MD_size(e) ((e)->md_size)
|
||||
#define EVP_MD_block_size(e) ((e)->block_size)
|
||||
|
||||
#define EVP_MD_CTX_md(e) ((e)->digest)
|
||||
#define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest)
|
||||
#define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest)
|
||||
#define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest)
|
||||
|
||||
#define EVP_CIPHER_nid(e) ((e)->nid)
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e))
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
#define EVP_CIPHER_block_size(e) ((e)->block_size)
|
||||
#define EVP_CIPHER_key_length(e) ((e)->key_len)
|
||||
#define EVP_CIPHER_iv_length(e) ((e)->iv_len)
|
||||
#define EVP_CIPHER_flags(e) ((e)->flags)
|
||||
#define EVP_CIPHER_mode(e) (((e)->flags) & EVP_CIPH_MODE)
|
||||
|
||||
#define EVP_CIPHER_CTX_cipher(e) ((e)->cipher)
|
||||
#define EVP_CIPHER_CTX_nid(e) ((e)->cipher->nid)
|
||||
#define EVP_CIPHER_CTX_block_size(e) ((e)->cipher->block_size)
|
||||
#define EVP_CIPHER_CTX_key_length(e) ((e)->key_len)
|
||||
#define EVP_CIPHER_CTX_iv_length(e) ((e)->cipher->iv_len)
|
||||
#define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data)
|
||||
#define EVP_CIPHER_CTX_set_app_data(e,d) ((e)->app_data=(char *)(d))
|
||||
#define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
|
||||
#define EVP_CIPHER_CTX_flags(e) ((e)->cipher->flags)
|
||||
#define EVP_CIPHER_CTX_mode(e) ((e)->cipher->flags & EVP_CIPH_MODE)
|
||||
|
||||
#define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80)
|
||||
#define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80)
|
||||
|
||||
#define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
|
||||
#define EVP_SignInit(a,b) EVP_DigestInit(a,b)
|
||||
#define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
|
||||
#define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
|
||||
#define EVP_VerifyInit(a,b) EVP_DigestInit(a,b)
|
||||
#define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
|
||||
#define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e)
|
||||
#define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e)
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#ifdef CONST_STRICT
|
||||
void BIO_set_md(BIO *,const EVP_MD *md);
|
||||
#else
|
||||
# define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md)
|
||||
#endif
|
||||
#define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp)
|
||||
#define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp)
|
||||
#define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)
|
||||
#define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp)
|
||||
|
||||
|
||||
#define EVP_Cipher(c,o,i,l) (c)->cipher->do_cipher((c),(o),(i),(l))
|
||||
|
||||
#define EVP_add_cipher_alias(n,alias) \
|
||||
OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n))
|
||||
#define EVP_add_digest_alias(n,alias) \
|
||||
OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n))
|
||||
#define EVP_delete_cipher_alias(alias) \
|
||||
OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS);
|
||||
#define EVP_delete_digest_alias(alias) \
|
||||
OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
|
||||
int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
|
||||
EVP_MD_CTX *EVP_MD_CTX_create(void);
|
||||
void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
|
||||
int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in);
|
||||
#define EVP_MD_CTX_set_flags(ctx,flgs) ((ctx)->flags|=(flgs))
|
||||
#define EVP_MD_CTX_clear_flags(ctx,flgs) ((ctx)->flags&=~(flgs))
|
||||
#define EVP_MD_CTX_test_flags(ctx,flgs) ((ctx)->flags&(flgs))
|
||||
int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
|
||||
int EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d,
|
||||
size_t cnt);
|
||||
int EVP_DigestFinal_ex(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
|
||||
int EVP_Digest(const void *data, size_t count,
|
||||
unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl);
|
||||
|
||||
int EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in);
|
||||
int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
|
||||
int EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
|
||||
|
||||
int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify);
|
||||
void EVP_set_pw_prompt(const char *prompt);
|
||||
char * EVP_get_pw_prompt(void);
|
||||
|
||||
int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md,
|
||||
const unsigned char *salt, const unsigned char *data,
|
||||
int datal, int count, unsigned char *key,unsigned char *iv);
|
||||
|
||||
int EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
|
||||
const unsigned char *key, const unsigned char *iv);
|
||||
int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
|
||||
const unsigned char *key, const unsigned char *iv);
|
||||
int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
int *outl, const unsigned char *in, int inl);
|
||||
int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
|
||||
int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
|
||||
|
||||
int EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
|
||||
const unsigned char *key, const unsigned char *iv);
|
||||
int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
|
||||
const unsigned char *key, const unsigned char *iv);
|
||||
int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
int *outl, const unsigned char *in, int inl);
|
||||
int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
|
||||
int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
|
||||
|
||||
int EVP_CipherInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
|
||||
const unsigned char *key,const unsigned char *iv,
|
||||
int enc);
|
||||
int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
|
||||
const unsigned char *key,const unsigned char *iv,
|
||||
int enc);
|
||||
int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
int *outl, const unsigned char *in, int inl);
|
||||
int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
|
||||
int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
|
||||
|
||||
int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s,
|
||||
EVP_PKEY *pkey);
|
||||
|
||||
int EVP_VerifyFinal(EVP_MD_CTX *ctx,const unsigned char *sigbuf,
|
||||
unsigned int siglen,EVP_PKEY *pkey);
|
||||
|
||||
int EVP_OpenInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type,
|
||||
const unsigned char *ek, int ekl, const unsigned char *iv,
|
||||
EVP_PKEY *priv);
|
||||
int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
|
||||
|
||||
int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
|
||||
unsigned char **ek, int *ekl, unsigned char *iv,
|
||||
EVP_PKEY **pubk, int npubk);
|
||||
int EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl);
|
||||
|
||||
void EVP_EncodeInit(EVP_ENCODE_CTX *ctx);
|
||||
void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl,
|
||||
const unsigned char *in,int inl);
|
||||
void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl);
|
||||
int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);
|
||||
|
||||
void EVP_DecodeInit(EVP_ENCODE_CTX *ctx);
|
||||
int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl,
|
||||
const unsigned char *in, int inl);
|
||||
int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
|
||||
char *out, int *outl);
|
||||
int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
|
||||
|
||||
void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
|
||||
int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
|
||||
EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);
|
||||
void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a);
|
||||
int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
|
||||
int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);
|
||||
int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
|
||||
int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key);
|
||||
|
||||
#ifndef OPENSSL_NO_BIO
|
||||
BIO_METHOD *BIO_f_md(void);
|
||||
BIO_METHOD *BIO_f_base64(void);
|
||||
BIO_METHOD *BIO_f_cipher(void);
|
||||
BIO_METHOD *BIO_f_reliable(void);
|
||||
void BIO_set_cipher(BIO *b,const EVP_CIPHER *c,const unsigned char *k,
|
||||
const unsigned char *i, int enc);
|
||||
#endif
|
||||
|
||||
const EVP_MD *EVP_md_null(void);
|
||||
#ifndef OPENSSL_NO_MD2
|
||||
const EVP_MD *EVP_md2(void);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MD4
|
||||
const EVP_MD *EVP_md4(void);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MD5
|
||||
const EVP_MD *EVP_md5(void);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SHA
|
||||
const EVP_MD *EVP_sha(void);
|
||||
const EVP_MD *EVP_sha1(void);
|
||||
const EVP_MD *EVP_dss(void);
|
||||
const EVP_MD *EVP_dss1(void);
|
||||
const EVP_MD *EVP_ecdsa(void);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SHA256
|
||||
const EVP_MD *EVP_sha224(void);
|
||||
const EVP_MD *EVP_sha256(void);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SHA512
|
||||
const EVP_MD *EVP_sha384(void);
|
||||
const EVP_MD *EVP_sha512(void);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MDC2
|
||||
const EVP_MD *EVP_mdc2(void);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RIPEMD
|
||||
const EVP_MD *EVP_ripemd160(void);
|
||||
#endif
|
||||
const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */
|
||||
#ifndef OPENSSL_NO_DES
|
||||
const EVP_CIPHER *EVP_des_ecb(void);
|
||||
const EVP_CIPHER *EVP_des_ede(void);
|
||||
const EVP_CIPHER *EVP_des_ede3(void);
|
||||
const EVP_CIPHER *EVP_des_ede_ecb(void);
|
||||
const EVP_CIPHER *EVP_des_ede3_ecb(void);
|
||||
const EVP_CIPHER *EVP_des_cfb64(void);
|
||||
# define EVP_des_cfb EVP_des_cfb64
|
||||
const EVP_CIPHER *EVP_des_cfb1(void);
|
||||
const EVP_CIPHER *EVP_des_cfb8(void);
|
||||
const EVP_CIPHER *EVP_des_ede_cfb64(void);
|
||||
# define EVP_des_ede_cfb EVP_des_ede_cfb64
|
||||
#if 0
|
||||
const EVP_CIPHER *EVP_des_ede_cfb1(void);
|
||||
const EVP_CIPHER *EVP_des_ede_cfb8(void);
|
||||
#endif
|
||||
const EVP_CIPHER *EVP_des_ede3_cfb64(void);
|
||||
# define EVP_des_ede3_cfb EVP_des_ede3_cfb64
|
||||
const EVP_CIPHER *EVP_des_ede3_cfb1(void);
|
||||
const EVP_CIPHER *EVP_des_ede3_cfb8(void);
|
||||
const EVP_CIPHER *EVP_des_ofb(void);
|
||||
const EVP_CIPHER *EVP_des_ede_ofb(void);
|
||||
const EVP_CIPHER *EVP_des_ede3_ofb(void);
|
||||
const EVP_CIPHER *EVP_des_cbc(void);
|
||||
const EVP_CIPHER *EVP_des_ede_cbc(void);
|
||||
const EVP_CIPHER *EVP_des_ede3_cbc(void);
|
||||
const EVP_CIPHER *EVP_desx_cbc(void);
|
||||
/* This should now be supported through the dev_crypto ENGINE. But also, why are
|
||||
* rc4 and md5 declarations made here inside a "NO_DES" precompiler branch? */
|
||||
#if 0
|
||||
# ifdef OPENSSL_OPENBSD_DEV_CRYPTO
|
||||
const EVP_CIPHER *EVP_dev_crypto_des_ede3_cbc(void);
|
||||
const EVP_CIPHER *EVP_dev_crypto_rc4(void);
|
||||
const EVP_MD *EVP_dev_crypto_md5(void);
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC4
|
||||
const EVP_CIPHER *EVP_rc4(void);
|
||||
const EVP_CIPHER *EVP_rc4_40(void);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
const EVP_CIPHER *EVP_idea_ecb(void);
|
||||
const EVP_CIPHER *EVP_idea_cfb64(void);
|
||||
# define EVP_idea_cfb EVP_idea_cfb64
|
||||
const EVP_CIPHER *EVP_idea_ofb(void);
|
||||
const EVP_CIPHER *EVP_idea_cbc(void);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC2
|
||||
const EVP_CIPHER *EVP_rc2_ecb(void);
|
||||
const EVP_CIPHER *EVP_rc2_cbc(void);
|
||||
const EVP_CIPHER *EVP_rc2_40_cbc(void);
|
||||
const EVP_CIPHER *EVP_rc2_64_cbc(void);
|
||||
const EVP_CIPHER *EVP_rc2_cfb64(void);
|
||||
# define EVP_rc2_cfb EVP_rc2_cfb64
|
||||
const EVP_CIPHER *EVP_rc2_ofb(void);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_BF
|
||||
const EVP_CIPHER *EVP_bf_ecb(void);
|
||||
const EVP_CIPHER *EVP_bf_cbc(void);
|
||||
const EVP_CIPHER *EVP_bf_cfb64(void);
|
||||
# define EVP_bf_cfb EVP_bf_cfb64
|
||||
const EVP_CIPHER *EVP_bf_ofb(void);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAST
|
||||
const EVP_CIPHER *EVP_cast5_ecb(void);
|
||||
const EVP_CIPHER *EVP_cast5_cbc(void);
|
||||
const EVP_CIPHER *EVP_cast5_cfb64(void);
|
||||
# define EVP_cast5_cfb EVP_cast5_cfb64
|
||||
const EVP_CIPHER *EVP_cast5_ofb(void);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC5
|
||||
const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);
|
||||
const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);
|
||||
const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void);
|
||||
# define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64
|
||||
const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_AES
|
||||
const EVP_CIPHER *EVP_aes_128_ecb(void);
|
||||
const EVP_CIPHER *EVP_aes_128_cbc(void);
|
||||
const EVP_CIPHER *EVP_aes_128_cfb1(void);
|
||||
const EVP_CIPHER *EVP_aes_128_cfb8(void);
|
||||
const EVP_CIPHER *EVP_aes_128_cfb128(void);
|
||||
# define EVP_aes_128_cfb EVP_aes_128_cfb128
|
||||
const EVP_CIPHER *EVP_aes_128_ofb(void);
|
||||
#if 0
|
||||
const EVP_CIPHER *EVP_aes_128_ctr(void);
|
||||
#endif
|
||||
const EVP_CIPHER *EVP_aes_192_ecb(void);
|
||||
const EVP_CIPHER *EVP_aes_192_cbc(void);
|
||||
const EVP_CIPHER *EVP_aes_192_cfb1(void);
|
||||
const EVP_CIPHER *EVP_aes_192_cfb8(void);
|
||||
const EVP_CIPHER *EVP_aes_192_cfb128(void);
|
||||
# define EVP_aes_192_cfb EVP_aes_192_cfb128
|
||||
const EVP_CIPHER *EVP_aes_192_ofb(void);
|
||||
#if 0
|
||||
const EVP_CIPHER *EVP_aes_192_ctr(void);
|
||||
#endif
|
||||
const EVP_CIPHER *EVP_aes_256_ecb(void);
|
||||
const EVP_CIPHER *EVP_aes_256_cbc(void);
|
||||
const EVP_CIPHER *EVP_aes_256_cfb1(void);
|
||||
const EVP_CIPHER *EVP_aes_256_cfb8(void);
|
||||
const EVP_CIPHER *EVP_aes_256_cfb128(void);
|
||||
# define EVP_aes_256_cfb EVP_aes_256_cfb128
|
||||
const EVP_CIPHER *EVP_aes_256_ofb(void);
|
||||
#if 0
|
||||
const EVP_CIPHER *EVP_aes_256_ctr(void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void OPENSSL_add_all_algorithms_noconf(void);
|
||||
void OPENSSL_add_all_algorithms_conf(void);
|
||||
|
||||
#ifdef OPENSSL_LOAD_CONF
|
||||
#define OpenSSL_add_all_algorithms() \
|
||||
OPENSSL_add_all_algorithms_conf()
|
||||
#else
|
||||
#define OpenSSL_add_all_algorithms() \
|
||||
OPENSSL_add_all_algorithms_noconf()
|
||||
#endif
|
||||
|
||||
void OpenSSL_add_all_ciphers(void);
|
||||
void OpenSSL_add_all_digests(void);
|
||||
#define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms()
|
||||
#define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers()
|
||||
#define SSLeay_add_all_digests() OpenSSL_add_all_digests()
|
||||
|
||||
int EVP_add_cipher(const EVP_CIPHER *cipher);
|
||||
int EVP_add_digest(const EVP_MD *digest);
|
||||
|
||||
const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
|
||||
const EVP_MD *EVP_get_digestbyname(const char *name);
|
||||
void EVP_cleanup(void);
|
||||
|
||||
int EVP_PKEY_decrypt(unsigned char *dec_key,
|
||||
const unsigned char *enc_key,int enc_key_len,
|
||||
EVP_PKEY *private_key);
|
||||
int EVP_PKEY_encrypt(unsigned char *enc_key,
|
||||
const unsigned char *key,int key_len,
|
||||
EVP_PKEY *pub_key);
|
||||
int EVP_PKEY_type(int type);
|
||||
int EVP_PKEY_bits(EVP_PKEY *pkey);
|
||||
int EVP_PKEY_size(EVP_PKEY *pkey);
|
||||
int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key);
|
||||
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
struct rsa_st;
|
||||
int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,struct rsa_st *key);
|
||||
struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
struct dsa_st;
|
||||
int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,struct dsa_st *key);
|
||||
struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DH
|
||||
struct dh_st;
|
||||
int EVP_PKEY_set1_DH(EVP_PKEY *pkey,struct dh_st *key);
|
||||
struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
struct ec_key_st;
|
||||
int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey,struct ec_key_st *key);
|
||||
struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);
|
||||
#endif
|
||||
|
||||
EVP_PKEY * EVP_PKEY_new(void);
|
||||
void EVP_PKEY_free(EVP_PKEY *pkey);
|
||||
|
||||
EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, const unsigned char **pp,
|
||||
long length);
|
||||
int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);
|
||||
|
||||
EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, const unsigned char **pp,
|
||||
long length);
|
||||
EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,
|
||||
long length);
|
||||
int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);
|
||||
|
||||
int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from);
|
||||
int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey);
|
||||
int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode);
|
||||
int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b);
|
||||
|
||||
int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);
|
||||
|
||||
int EVP_CIPHER_type(const EVP_CIPHER *ctx);
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
/* calls methods */
|
||||
int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
|
||||
int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
|
||||
|
||||
/* These are used by EVP_CIPHER methods */
|
||||
int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type);
|
||||
int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type);
|
||||
|
||||
|
||||
/* PKCS5 password based encryption */
|
||||
int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
|
||||
ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
|
||||
int en_de);
|
||||
int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
|
||||
const unsigned char *salt, int saltlen, int iter,
|
||||
int keylen, unsigned char *out);
|
||||
int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
|
||||
ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
|
||||
int en_de);
|
||||
|
||||
void PKCS5_PBE_add(void);
|
||||
|
||||
int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
|
||||
ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);
|
||||
int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
|
||||
EVP_PBE_KEYGEN *keygen);
|
||||
void EVP_PBE_cleanup(void);
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
/* 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_EVP_strings(void);
|
||||
|
||||
/* Error codes for the EVP functions. */
|
||||
|
||||
/* Function codes. */
|
||||
#define EVP_F_AES_INIT_KEY 133
|
||||
#define EVP_F_D2I_PKEY 100
|
||||
#define EVP_F_DSAPKEY2PKCS8 134
|
||||
#define EVP_F_DSA_PKEY2PKCS8 135
|
||||
#define EVP_F_ECDSA_PKEY2PKCS8 129
|
||||
#define EVP_F_ECKEY_PKEY2PKCS8 132
|
||||
#define EVP_F_EVP_CIPHERINIT_EX 123
|
||||
#define EVP_F_EVP_CIPHER_CTX_CTRL 124
|
||||
#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122
|
||||
#define EVP_F_EVP_DECRYPTFINAL_EX 101
|
||||
#define EVP_F_EVP_DIGESTINIT_EX 128
|
||||
#define EVP_F_EVP_ENCRYPTFINAL_EX 127
|
||||
#define EVP_F_EVP_MD_CTX_COPY_EX 110
|
||||
#define EVP_F_EVP_OPENINIT 102
|
||||
#define EVP_F_EVP_PBE_ALG_ADD 115
|
||||
#define EVP_F_EVP_PBE_CIPHERINIT 116
|
||||
#define EVP_F_EVP_PKCS82PKEY 111
|
||||
#define EVP_F_EVP_PKEY2PKCS8_BROKEN 113
|
||||
#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103
|
||||
#define EVP_F_EVP_PKEY_DECRYPT 104
|
||||
#define EVP_F_EVP_PKEY_ENCRYPT 105
|
||||
#define EVP_F_EVP_PKEY_GET1_DH 119
|
||||
#define EVP_F_EVP_PKEY_GET1_DSA 120
|
||||
#define EVP_F_EVP_PKEY_GET1_ECDSA 130
|
||||
#define EVP_F_EVP_PKEY_GET1_EC_KEY 131
|
||||
#define EVP_F_EVP_PKEY_GET1_RSA 121
|
||||
#define EVP_F_EVP_PKEY_NEW 106
|
||||
#define EVP_F_EVP_RIJNDAEL 126
|
||||
#define EVP_F_EVP_SIGNFINAL 107
|
||||
#define EVP_F_EVP_VERIFYFINAL 108
|
||||
#define EVP_F_PKCS5_PBE_KEYIVGEN 117
|
||||
#define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118
|
||||
#define EVP_F_PKCS8_SET_BROKEN 112
|
||||
#define EVP_F_RC2_MAGIC_TO_METH 109
|
||||
#define EVP_F_RC5_CTRL 125
|
||||
|
||||
/* Reason codes. */
|
||||
#define EVP_R_AES_KEY_SETUP_FAILED 143
|
||||
#define EVP_R_ASN1_LIB 140
|
||||
#define EVP_R_BAD_BLOCK_LENGTH 136
|
||||
#define EVP_R_BAD_DECRYPT 100
|
||||
#define EVP_R_BAD_KEY_LENGTH 137
|
||||
#define EVP_R_BN_DECODE_ERROR 112
|
||||
#define EVP_R_BN_PUBKEY_ERROR 113
|
||||
#define EVP_R_CIPHER_PARAMETER_ERROR 122
|
||||
#define EVP_R_CTRL_NOT_IMPLEMENTED 132
|
||||
#define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133
|
||||
#define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138
|
||||
#define EVP_R_DECODE_ERROR 114
|
||||
#define EVP_R_DIFFERENT_KEY_TYPES 101
|
||||
#define EVP_R_ENCODE_ERROR 115
|
||||
#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119
|
||||
#define EVP_R_EXPECTING_AN_RSA_KEY 127
|
||||
#define EVP_R_EXPECTING_A_DH_KEY 128
|
||||
#define EVP_R_EXPECTING_A_DSA_KEY 129
|
||||
#define EVP_R_EXPECTING_A_ECDSA_KEY 141
|
||||
#define EVP_R_EXPECTING_A_EC_KEY 142
|
||||
#define EVP_R_INITIALIZATION_ERROR 134
|
||||
#define EVP_R_INPUT_NOT_INITIALIZED 111
|
||||
#define EVP_R_INVALID_KEY_LENGTH 130
|
||||
#define EVP_R_IV_TOO_LARGE 102
|
||||
#define EVP_R_KEYGEN_FAILURE 120
|
||||
#define EVP_R_MISSING_PARAMETERS 103
|
||||
#define EVP_R_NO_CIPHER_SET 131
|
||||
#define EVP_R_NO_DIGEST_SET 139
|
||||
#define EVP_R_NO_DSA_PARAMETERS 116
|
||||
#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104
|
||||
#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105
|
||||
#define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117
|
||||
#define EVP_R_PUBLIC_KEY_NOT_RSA 106
|
||||
#define EVP_R_UNKNOWN_PBE_ALGORITHM 121
|
||||
#define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135
|
||||
#define EVP_R_UNSUPPORTED_CIPHER 107
|
||||
#define EVP_R_UNSUPPORTED_KEYLENGTH 123
|
||||
#define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124
|
||||
#define EVP_R_UNSUPPORTED_KEY_SIZE 108
|
||||
#define EVP_R_UNSUPPORTED_PRF 125
|
||||
#define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118
|
||||
#define EVP_R_UNSUPPORTED_SALT_TYPE 126
|
||||
#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109
|
||||
#define EVP_R_WRONG_PUBLIC_KEY_TYPE 110
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
236
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/evp_locl.h
Executable file
236
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/evp_locl.h
Executable file
@ -0,0 +1,236 @@
|
||||
/* evp_locl.h */
|
||||
/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
|
||||
* project 2000.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* 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
|
||||
* licensing@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).
|
||||
*
|
||||
*/
|
||||
|
||||
/* Macros to code block cipher wrappers */
|
||||
|
||||
/* Wrapper functions for each cipher mode */
|
||||
|
||||
#define BLOCK_CIPHER_ecb_loop() \
|
||||
unsigned int i, bl; \
|
||||
bl = ctx->cipher->block_size;\
|
||||
if(inl < bl) return 1;\
|
||||
inl -= bl; \
|
||||
for(i=0; i <= inl; i+=bl) \
|
||||
|
||||
#define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
|
||||
static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \
|
||||
{\
|
||||
BLOCK_CIPHER_ecb_loop() \
|
||||
cprefix##_ecb_encrypt(in + i, out + i, &((kstruct *)ctx->cipher_data)->ksched, ctx->encrypt);\
|
||||
return 1;\
|
||||
}
|
||||
|
||||
#define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \
|
||||
static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \
|
||||
{\
|
||||
cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num);\
|
||||
return 1;\
|
||||
}
|
||||
|
||||
#define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
|
||||
static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \
|
||||
{\
|
||||
cprefix##_cbc_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, ctx->encrypt);\
|
||||
return 1;\
|
||||
}
|
||||
|
||||
#define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
|
||||
static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \
|
||||
{\
|
||||
cprefix##_cfb##cbits##_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num, ctx->encrypt);\
|
||||
return 1;\
|
||||
}
|
||||
|
||||
#define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
|
||||
BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
|
||||
BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
|
||||
BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
|
||||
BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched)
|
||||
|
||||
#define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \
|
||||
key_len, iv_len, flags, init_key, cleanup, \
|
||||
set_asn1, get_asn1, ctrl) \
|
||||
static const EVP_CIPHER cname##_##mode = { \
|
||||
nid##_##nmode, block_size, key_len, iv_len, \
|
||||
flags | EVP_CIPH_##MODE##_MODE, \
|
||||
init_key, \
|
||||
cname##_##mode##_cipher, \
|
||||
cleanup, \
|
||||
sizeof(kstruct), \
|
||||
set_asn1, get_asn1,\
|
||||
ctrl, \
|
||||
NULL \
|
||||
}; \
|
||||
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
|
||||
|
||||
#define BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, \
|
||||
iv_len, flags, init_key, cleanup, set_asn1, \
|
||||
get_asn1, ctrl) \
|
||||
BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \
|
||||
iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
|
||||
|
||||
#define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, \
|
||||
iv_len, cbits, flags, init_key, cleanup, \
|
||||
set_asn1, get_asn1, ctrl) \
|
||||
BLOCK_CIPHER_def1(cname, cfb##cbits, cfb##cbits, CFB, kstruct, nid, 1, \
|
||||
key_len, iv_len, flags, init_key, cleanup, set_asn1, \
|
||||
get_asn1, ctrl)
|
||||
|
||||
#define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, \
|
||||
iv_len, cbits, flags, init_key, cleanup, \
|
||||
set_asn1, get_asn1, ctrl) \
|
||||
BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, \
|
||||
key_len, iv_len, flags, init_key, cleanup, set_asn1, \
|
||||
get_asn1, ctrl)
|
||||
|
||||
#define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \
|
||||
iv_len, flags, init_key, cleanup, set_asn1, \
|
||||
get_asn1, ctrl) \
|
||||
BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \
|
||||
iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
|
||||
|
||||
#define BLOCK_CIPHER_defs(cname, kstruct, \
|
||||
nid, block_size, key_len, iv_len, cbits, flags, \
|
||||
init_key, cleanup, set_asn1, get_asn1, ctrl) \
|
||||
BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, \
|
||||
init_key, cleanup, set_asn1, get_asn1, ctrl) \
|
||||
BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, \
|
||||
flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
|
||||
BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \
|
||||
flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
|
||||
BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, iv_len, flags, \
|
||||
init_key, cleanup, set_asn1, get_asn1, ctrl)
|
||||
|
||||
|
||||
/*
|
||||
#define BLOCK_CIPHER_defs(cname, kstruct, \
|
||||
nid, block_size, key_len, iv_len, flags,\
|
||||
init_key, cleanup, set_asn1, get_asn1, ctrl)\
|
||||
static const EVP_CIPHER cname##_cbc = {\
|
||||
nid##_cbc, block_size, key_len, iv_len, \
|
||||
flags | EVP_CIPH_CBC_MODE,\
|
||||
init_key,\
|
||||
cname##_cbc_cipher,\
|
||||
cleanup,\
|
||||
sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
|
||||
sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
|
||||
set_asn1, get_asn1,\
|
||||
ctrl, \
|
||||
NULL \
|
||||
};\
|
||||
const EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\
|
||||
static const EVP_CIPHER cname##_cfb = {\
|
||||
nid##_cfb64, 1, key_len, iv_len, \
|
||||
flags | EVP_CIPH_CFB_MODE,\
|
||||
init_key,\
|
||||
cname##_cfb_cipher,\
|
||||
cleanup,\
|
||||
sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
|
||||
sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
|
||||
set_asn1, get_asn1,\
|
||||
ctrl,\
|
||||
NULL \
|
||||
};\
|
||||
const EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\
|
||||
static const EVP_CIPHER cname##_ofb = {\
|
||||
nid##_ofb64, 1, key_len, iv_len, \
|
||||
flags | EVP_CIPH_OFB_MODE,\
|
||||
init_key,\
|
||||
cname##_ofb_cipher,\
|
||||
cleanup,\
|
||||
sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
|
||||
sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
|
||||
set_asn1, get_asn1,\
|
||||
ctrl,\
|
||||
NULL \
|
||||
};\
|
||||
const EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\
|
||||
static const EVP_CIPHER cname##_ecb = {\
|
||||
nid##_ecb, block_size, key_len, iv_len, \
|
||||
flags | EVP_CIPH_ECB_MODE,\
|
||||
init_key,\
|
||||
cname##_ecb_cipher,\
|
||||
cleanup,\
|
||||
sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
|
||||
sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
|
||||
set_asn1, get_asn1,\
|
||||
ctrl,\
|
||||
NULL \
|
||||
};\
|
||||
const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }
|
||||
*/
|
||||
|
||||
#define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \
|
||||
block_size, key_len, iv_len, cbits, \
|
||||
flags, init_key, \
|
||||
cleanup, set_asn1, get_asn1, ctrl) \
|
||||
BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
|
||||
BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \
|
||||
cbits, flags, init_key, cleanup, set_asn1, \
|
||||
get_asn1, ctrl)
|
||||
|
||||
#define EVP_C_DATA(kstruct, ctx) ((kstruct *)(ctx)->cipher_data)
|
||||
|
||||
#define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len) \
|
||||
BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \
|
||||
BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \
|
||||
NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \
|
||||
0, cipher##_init_key, NULL, \
|
||||
EVP_CIPHER_set_asn1_iv, \
|
||||
EVP_CIPHER_get_asn1_iv, \
|
||||
NULL)
|
132
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/fips.h
Executable file
132
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/fips.h
Executable file
@ -0,0 +1,132 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2003 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
|
||||
#ifdef OPENSSL_FIPS
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct dsa_st;
|
||||
|
||||
int FIPS_mode_set(int onoff,const char *path);
|
||||
#define FIPS_init(f) FIPS_mode_set((f),NULL)
|
||||
int FIPS_mode(void);
|
||||
const void *FIPS_rand_check(void);
|
||||
int FIPS_selftest_failed(void);
|
||||
int FIPS_dsa_check(struct dsa_st *dsa);
|
||||
void FIPS_corrupt_sha1(void);
|
||||
int FIPS_selftest_sha1(void);
|
||||
void FIPS_corrupt_aes(void);
|
||||
int FIPS_selftest_aes(void);
|
||||
void FIPS_corrupt_des(void);
|
||||
int FIPS_selftest_des(void);
|
||||
void FIPS_corrupt_rsa(void);
|
||||
int FIPS_selftest_rsa(void);
|
||||
void FIPS_corrupt_dsa(void);
|
||||
int FIPS_selftest_dsa(void);
|
||||
void FIPS_corrupt_rng(void);
|
||||
int FIPS_selftest_rng(void);
|
||||
int FIPS_selftest_hmac(void);
|
||||
|
||||
/* 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_FIPS_strings(void);
|
||||
|
||||
/* 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_FIPS_strings(void);
|
||||
|
||||
/* Error codes for the FIPS functions. */
|
||||
|
||||
/* Function codes. */
|
||||
#define FIPS_F_DH_GENERATE_PARAMETERS 117
|
||||
#define FIPS_F_DSA_DO_SIGN 111
|
||||
#define FIPS_F_DSA_DO_VERIFY 112
|
||||
#define FIPS_F_DSA_GENERATE_PARAMETERS 110
|
||||
#define FIPS_F_FIPS_CHECK_DSA 116
|
||||
#define FIPS_F_FIPS_CHECK_EXE 106
|
||||
#define FIPS_F_FIPS_CHECK_RSA 115
|
||||
#define FIPS_F_FIPS_DSA_CHECK 102
|
||||
#define FIPS_F_FIPS_MODE_SET 105
|
||||
#define FIPS_F_FIPS_SELFTEST_AES 104
|
||||
#define FIPS_F_FIPS_SELFTEST_DES 107
|
||||
#define FIPS_F_FIPS_SELFTEST_DSA 109
|
||||
#define FIPS_F_FIPS_SELFTEST_RNG 118
|
||||
#define FIPS_F_FIPS_SELFTEST_RSA 108
|
||||
#define FIPS_F_FIPS_SELFTEST_SHA 103
|
||||
#define FIPS_F_HASH_FINAL 100
|
||||
#define FIPS_F_RSA_EAY_PUBLIC_ENCRYPT 114
|
||||
#define FIPS_F_RSA_GENERATE_KEY 113
|
||||
#define FIPS_F_RSA_X931_GENERATE_KEY 119
|
||||
#define FIPS_F_SSLEAY_RAND_BYTES 101
|
||||
#define FIPS_F_FIPS_CHECK_DSO 120
|
||||
|
||||
/* Reason codes. */
|
||||
#define FIPS_R_CANNOT_READ_EXE 103
|
||||
#define FIPS_R_CANNOT_READ_EXE_DIGEST 104
|
||||
#define FIPS_R_EXE_DIGEST_DOES_NOT_MATCH 105
|
||||
#define FIPS_R_FIPS_MODE_ALREADY_SET 102
|
||||
#define FIPS_R_FIPS_SELFTEST_FAILED 106
|
||||
#define FIPS_R_INVALID_KEY_LENGTH 109
|
||||
#define FIPS_R_KEY_TOO_SHORT 108
|
||||
#define FIPS_R_NON_FIPS_METHOD 100
|
||||
#define FIPS_R_PAIRWISE_TEST_FAILED 107
|
||||
#define FIPS_R_SELFTEST_FAILED 101
|
||||
#define FIPS_R_NO_DSO_PATH 110
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -0,0 +1,73 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2003 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_FIPS_RAND_H
|
||||
#define HEADER_FIPS_RAND_H
|
||||
|
||||
#include "des.h"
|
||||
|
||||
#ifdef OPENSSL_FIPS
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void FIPS_set_prng_key(const unsigned char k1[8],const unsigned char k2[8]);
|
||||
void FIPS_test_mode(int test,const unsigned char faketime[8]);
|
||||
void FIPS_rand_seed(const void *buf, FIPS_RAND_SIZE_T num);
|
||||
/* NB: this returns true if _partially_ seeded */
|
||||
int FIPS_rand_seeded(void);
|
||||
|
||||
const RAND_METHOD *FIPS_rand_method(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
112
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/hmac.h
Executable file
112
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/hmac.h
Executable file
@ -0,0 +1,112 @@
|
||||
/* crypto/hmac/hmac.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
#ifndef HEADER_HMAC_H
|
||||
#define HEADER_HMAC_H
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#include <openssl/opensslconf.h>
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
#ifdef OPENSSL_NO_HMAC
|
||||
#error HMAC is disabled.
|
||||
#endif
|
||||
|
||||
#include <openssl/evp.h>
|
||||
|
||||
#define HMAC_MAX_MD_CBLOCK 128 /* largest known is SHA512 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct hmac_ctx_st
|
||||
{
|
||||
const EVP_MD *md;
|
||||
EVP_MD_CTX md_ctx;
|
||||
EVP_MD_CTX i_ctx;
|
||||
EVP_MD_CTX o_ctx;
|
||||
unsigned int key_length;
|
||||
unsigned char key[HMAC_MAX_MD_CBLOCK];
|
||||
} HMAC_CTX;
|
||||
|
||||
#define HMAC_size(e) (EVP_MD_size((e)->md))
|
||||
|
||||
|
||||
void HMAC_CTX_init(HMAC_CTX *ctx);
|
||||
void HMAC_CTX_cleanup(HMAC_CTX *ctx);
|
||||
|
||||
#define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx) /* deprecated */
|
||||
|
||||
void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
|
||||
const EVP_MD *md); /* deprecated */
|
||||
void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
|
||||
const EVP_MD *md, ENGINE *impl);
|
||||
void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len);
|
||||
void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
|
||||
unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
|
||||
const unsigned char *d, size_t n, unsigned char *md,
|
||||
unsigned int *md_len);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
199
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/lhash.h
Executable file
199
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/lhash.h
Executable file
@ -0,0 +1,199 @@
|
||||
/* crypto/lhash/lhash.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/* Header for dynamic hash table routines
|
||||
* Author - Eric Young
|
||||
*/
|
||||
|
||||
#ifndef HEADER_LHASH_H
|
||||
#define HEADER_LHASH_H
|
||||
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_BIO
|
||||
#include <openssl/bio.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct lhash_node_st
|
||||
{
|
||||
const void *data;
|
||||
struct lhash_node_st *next;
|
||||
#ifndef OPENSSL_NO_HASH_COMP
|
||||
unsigned long hash;
|
||||
#endif
|
||||
} LHASH_NODE;
|
||||
|
||||
typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *);
|
||||
typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *);
|
||||
typedef void (*LHASH_DOALL_FN_TYPE)(const void *);
|
||||
typedef void (*LHASH_DOALL_ARG_FN_TYPE)(const void *, void *);
|
||||
|
||||
/* Macros for declaring and implementing type-safe wrappers for LHASH callbacks.
|
||||
* This way, callbacks can be provided to LHASH structures without function
|
||||
* pointer casting and the macro-defined callbacks provide per-variable casting
|
||||
* before deferring to the underlying type-specific callbacks. NB: It is
|
||||
* possible to place a "static" in front of both the DECLARE and IMPLEMENT
|
||||
* macros if the functions are strictly internal. */
|
||||
|
||||
/* First: "hash" functions */
|
||||
#define DECLARE_LHASH_HASH_FN(f_name,o_type) \
|
||||
unsigned long f_name##_LHASH_HASH(const void *);
|
||||
#define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \
|
||||
unsigned long f_name##_LHASH_HASH(const void *arg) { \
|
||||
o_type a = (o_type)arg; \
|
||||
return f_name(a); }
|
||||
#define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH
|
||||
|
||||
/* Second: "compare" functions */
|
||||
#define DECLARE_LHASH_COMP_FN(f_name,o_type) \
|
||||
int f_name##_LHASH_COMP(const void *, const void *);
|
||||
#define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \
|
||||
int f_name##_LHASH_COMP(const void *arg1, const void *arg2) { \
|
||||
o_type a = (o_type)arg1; \
|
||||
o_type b = (o_type)arg2; \
|
||||
return f_name(a,b); }
|
||||
#define LHASH_COMP_FN(f_name) f_name##_LHASH_COMP
|
||||
|
||||
/* Third: "doall" functions */
|
||||
#define DECLARE_LHASH_DOALL_FN(f_name,o_type) \
|
||||
void f_name##_LHASH_DOALL(const void *);
|
||||
#define IMPLEMENT_LHASH_DOALL_FN(f_name,o_type) \
|
||||
void f_name##_LHASH_DOALL(const void *arg) { \
|
||||
o_type a = (o_type)arg; \
|
||||
f_name(a); }
|
||||
#define LHASH_DOALL_FN(f_name) f_name##_LHASH_DOALL
|
||||
|
||||
/* Fourth: "doall_arg" functions */
|
||||
#define DECLARE_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
|
||||
void f_name##_LHASH_DOALL_ARG(const void *, void *);
|
||||
#define IMPLEMENT_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
|
||||
void f_name##_LHASH_DOALL_ARG(const void *arg1, void *arg2) { \
|
||||
o_type a = (o_type)arg1; \
|
||||
a_type b = (a_type)arg2; \
|
||||
f_name(a,b); }
|
||||
#define LHASH_DOALL_ARG_FN(f_name) f_name##_LHASH_DOALL_ARG
|
||||
|
||||
typedef struct lhash_st
|
||||
{
|
||||
LHASH_NODE **b;
|
||||
LHASH_COMP_FN_TYPE comp;
|
||||
LHASH_HASH_FN_TYPE hash;
|
||||
unsigned int num_nodes;
|
||||
unsigned int num_alloc_nodes;
|
||||
unsigned int p;
|
||||
unsigned int pmax;
|
||||
unsigned long up_load; /* load times 256 */
|
||||
unsigned long down_load; /* load times 256 */
|
||||
unsigned long num_items;
|
||||
|
||||
unsigned long num_expands;
|
||||
unsigned long num_expand_reallocs;
|
||||
unsigned long num_contracts;
|
||||
unsigned long num_contract_reallocs;
|
||||
unsigned long num_hash_calls;
|
||||
unsigned long num_comp_calls;
|
||||
unsigned long num_insert;
|
||||
unsigned long num_replace;
|
||||
unsigned long num_delete;
|
||||
unsigned long num_no_delete;
|
||||
unsigned long num_retrieve;
|
||||
unsigned long num_retrieve_miss;
|
||||
unsigned long num_hash_comps;
|
||||
|
||||
int error;
|
||||
} LHASH;
|
||||
|
||||
#define LH_LOAD_MULT 256
|
||||
|
||||
/* Indicates a malloc() error in the last call, this is only bad
|
||||
* in lh_insert(). */
|
||||
#define lh_error(lh) ((lh)->error)
|
||||
|
||||
LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c);
|
||||
void lh_free(LHASH *lh);
|
||||
void *lh_insert(LHASH *lh, const void *data);
|
||||
void *lh_delete(LHASH *lh, const void *data);
|
||||
void *lh_retrieve(LHASH *lh, const void *data);
|
||||
void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func);
|
||||
void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg);
|
||||
unsigned long lh_strhash(const char *c);
|
||||
unsigned long lh_num_items(const LHASH *lh);
|
||||
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
void lh_stats(const LHASH *lh, FILE *out);
|
||||
void lh_node_stats(const LHASH *lh, FILE *out);
|
||||
void lh_node_usage_stats(const LHASH *lh, FILE *out);
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_BIO
|
||||
void lh_stats_bio(const LHASH *lh, BIO *out);
|
||||
void lh_node_stats_bio(const LHASH *lh, BIO *out);
|
||||
void lh_node_usage_stats_bio(const LHASH *lh, BIO *out);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,623 @@
|
||||
/* crypto/md32_common.h */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2002 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
|
||||
* licensing@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).
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is a generic 32 bit "collector" for message digest algorithms.
|
||||
* Whenever needed it collects input character stream into chunks of
|
||||
* 32 bit values and invokes a block function that performs actual hash
|
||||
* calculations.
|
||||
*
|
||||
* Porting guide.
|
||||
*
|
||||
* Obligatory macros:
|
||||
*
|
||||
* DATA_ORDER_IS_BIG_ENDIAN or DATA_ORDER_IS_LITTLE_ENDIAN
|
||||
* this macro defines byte order of input stream.
|
||||
* HASH_CBLOCK
|
||||
* size of a unit chunk HASH_BLOCK operates on.
|
||||
* HASH_LONG
|
||||
* has to be at lest 32 bit wide, if it's wider, then
|
||||
* HASH_LONG_LOG2 *has to* be defined along
|
||||
* HASH_CTX
|
||||
* context structure that at least contains following
|
||||
* members:
|
||||
* typedef struct {
|
||||
* ...
|
||||
* HASH_LONG Nl,Nh;
|
||||
* HASH_LONG data[HASH_LBLOCK];
|
||||
* unsigned int num;
|
||||
* ...
|
||||
* } HASH_CTX;
|
||||
* HASH_UPDATE
|
||||
* name of "Update" function, implemented here.
|
||||
* HASH_TRANSFORM
|
||||
* name of "Transform" function, implemented here.
|
||||
* HASH_FINAL
|
||||
* name of "Final" function, implemented here.
|
||||
* HASH_BLOCK_HOST_ORDER
|
||||
* name of "block" function treating *aligned* input message
|
||||
* in host byte order, implemented externally.
|
||||
* HASH_BLOCK_DATA_ORDER
|
||||
* name of "block" function treating *unaligned* input message
|
||||
* in original (data) byte order, implemented externally (it
|
||||
* actually is optional if data and host are of the same
|
||||
* "endianess").
|
||||
* HASH_MAKE_STRING
|
||||
* macro convering context variables to an ASCII hash string.
|
||||
*
|
||||
* Optional macros:
|
||||
*
|
||||
* B_ENDIAN or L_ENDIAN
|
||||
* defines host byte-order.
|
||||
* HASH_LONG_LOG2
|
||||
* defaults to 2 if not states otherwise.
|
||||
* HASH_LBLOCK
|
||||
* assumed to be HASH_CBLOCK/4 if not stated otherwise.
|
||||
* HASH_BLOCK_DATA_ORDER_ALIGNED
|
||||
* alternative "block" function capable of treating
|
||||
* aligned input message in original (data) order,
|
||||
* implemented externally.
|
||||
*
|
||||
* MD5 example:
|
||||
*
|
||||
* #define DATA_ORDER_IS_LITTLE_ENDIAN
|
||||
*
|
||||
* #define HASH_LONG MD5_LONG
|
||||
* #define HASH_LONG_LOG2 MD5_LONG_LOG2
|
||||
* #define HASH_CTX MD5_CTX
|
||||
* #define HASH_CBLOCK MD5_CBLOCK
|
||||
* #define HASH_LBLOCK MD5_LBLOCK
|
||||
* #define HASH_UPDATE MD5_Update
|
||||
* #define HASH_TRANSFORM MD5_Transform
|
||||
* #define HASH_FINAL MD5_Final
|
||||
* #define HASH_BLOCK_HOST_ORDER md5_block_host_order
|
||||
* #define HASH_BLOCK_DATA_ORDER md5_block_data_order
|
||||
*
|
||||
* <appro@fy.chalmers.se>
|
||||
*/
|
||||
|
||||
#if !defined(DATA_ORDER_IS_BIG_ENDIAN) && !defined(DATA_ORDER_IS_LITTLE_ENDIAN)
|
||||
#error "DATA_ORDER must be defined!"
|
||||
#endif
|
||||
|
||||
#ifndef HASH_CBLOCK
|
||||
#error "HASH_CBLOCK must be defined!"
|
||||
#endif
|
||||
#ifndef HASH_LONG
|
||||
#error "HASH_LONG must be defined!"
|
||||
#endif
|
||||
#ifndef HASH_CTX
|
||||
#error "HASH_CTX must be defined!"
|
||||
#endif
|
||||
|
||||
#ifndef HASH_UPDATE
|
||||
#error "HASH_UPDATE must be defined!"
|
||||
#endif
|
||||
#ifndef HASH_TRANSFORM
|
||||
#error "HASH_TRANSFORM must be defined!"
|
||||
#endif
|
||||
#ifndef HASH_FINAL
|
||||
#error "HASH_FINAL must be defined!"
|
||||
#endif
|
||||
|
||||
#ifndef HASH_BLOCK_HOST_ORDER
|
||||
#error "HASH_BLOCK_HOST_ORDER must be defined!"
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Moved below as it's required only if HASH_BLOCK_DATA_ORDER_ALIGNED
|
||||
* isn't defined.
|
||||
*/
|
||||
#ifndef HASH_BLOCK_DATA_ORDER
|
||||
#error "HASH_BLOCK_DATA_ORDER must be defined!"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef HASH_LBLOCK
|
||||
#define HASH_LBLOCK (HASH_CBLOCK/4)
|
||||
#endif
|
||||
|
||||
#ifndef HASH_LONG_LOG2
|
||||
#define HASH_LONG_LOG2 2
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Engage compiler specific rotate intrinsic function if available.
|
||||
*/
|
||||
#undef ROTATE
|
||||
#ifndef PEDANTIC
|
||||
# if defined(_MSC_VER) || defined(__ICC)
|
||||
# define ROTATE(a,n) _lrotl(a,n)
|
||||
# elif defined(__MWERKS__)
|
||||
# if defined(__POWERPC__)
|
||||
# define ROTATE(a,n) __rlwinm(a,n,0,31)
|
||||
# elif defined(__MC68K__)
|
||||
/* Motorola specific tweak. <appro@fy.chalmers.se> */
|
||||
# define ROTATE(a,n) ( n<24 ? __rol(a,n) : __ror(a,32-n) )
|
||||
# else
|
||||
# define ROTATE(a,n) __rol(a,n)
|
||||
# endif
|
||||
# elif defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
|
||||
/*
|
||||
* Some GNU C inline assembler templates. Note that these are
|
||||
* rotates by *constant* number of bits! But that's exactly
|
||||
* what we need here...
|
||||
* <appro@fy.chalmers.se>
|
||||
*/
|
||||
# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)
|
||||
# define ROTATE(a,n) ({ register unsigned int ret; \
|
||||
asm ( \
|
||||
"roll %1,%0" \
|
||||
: "=r"(ret) \
|
||||
: "I"(n), "0"(a) \
|
||||
: "cc"); \
|
||||
ret; \
|
||||
})
|
||||
# elif defined(__powerpc) || defined(__ppc__) || defined(__powerpc64__)
|
||||
# define ROTATE(a,n) ({ register unsigned int ret; \
|
||||
asm ( \
|
||||
"rlwinm %0,%1,%2,0,31" \
|
||||
: "=r"(ret) \
|
||||
: "r"(a), "I"(n)); \
|
||||
ret; \
|
||||
})
|
||||
# endif
|
||||
# endif
|
||||
#endif /* PEDANTIC */
|
||||
|
||||
#if HASH_LONG_LOG2==2 /* Engage only if sizeof(HASH_LONG)== 4 */
|
||||
/* A nice byte order reversal from Wei Dai <weidai@eskimo.com> */
|
||||
#ifdef ROTATE
|
||||
/* 5 instructions with rotate instruction, else 9 */
|
||||
#define REVERSE_FETCH32(a,l) ( \
|
||||
l=*(const HASH_LONG *)(a), \
|
||||
((ROTATE(l,8)&0x00FF00FF)|(ROTATE((l&0x00FF00FF),24))) \
|
||||
)
|
||||
#else
|
||||
/* 6 instructions with rotate instruction, else 8 */
|
||||
#define REVERSE_FETCH32(a,l) ( \
|
||||
l=*(const HASH_LONG *)(a), \
|
||||
l=(((l>>8)&0x00FF00FF)|((l&0x00FF00FF)<<8)), \
|
||||
ROTATE(l,16) \
|
||||
)
|
||||
/*
|
||||
* Originally the middle line started with l=(((l&0xFF00FF00)>>8)|...
|
||||
* It's rewritten as above for two reasons:
|
||||
* - RISCs aren't good at long constants and have to explicitely
|
||||
* compose 'em with several (well, usually 2) instructions in a
|
||||
* register before performing the actual operation and (as you
|
||||
* already realized:-) having same constant should inspire the
|
||||
* compiler to permanently allocate the only register for it;
|
||||
* - most modern CPUs have two ALUs, but usually only one has
|
||||
* circuitry for shifts:-( this minor tweak inspires compiler
|
||||
* to schedule shift instructions in a better way...
|
||||
*
|
||||
* <appro@fy.chalmers.se>
|
||||
*/
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ROTATE
|
||||
#define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n))))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Make some obvious choices. E.g., HASH_BLOCK_DATA_ORDER_ALIGNED
|
||||
* and HASH_BLOCK_HOST_ORDER ought to be the same if input data
|
||||
* and host are of the same "endianess". It's possible to mask
|
||||
* this with blank #define HASH_BLOCK_DATA_ORDER though...
|
||||
*
|
||||
* <appro@fy.chalmers.se>
|
||||
*/
|
||||
#if defined(B_ENDIAN)
|
||||
# if defined(DATA_ORDER_IS_BIG_ENDIAN)
|
||||
# if !defined(HASH_BLOCK_DATA_ORDER_ALIGNED) && HASH_LONG_LOG2==2
|
||||
# define HASH_BLOCK_DATA_ORDER_ALIGNED HASH_BLOCK_HOST_ORDER
|
||||
# endif
|
||||
# endif
|
||||
#elif defined(L_ENDIAN)
|
||||
# if defined(DATA_ORDER_IS_LITTLE_ENDIAN)
|
||||
# if !defined(HASH_BLOCK_DATA_ORDER_ALIGNED) && HASH_LONG_LOG2==2
|
||||
# define HASH_BLOCK_DATA_ORDER_ALIGNED HASH_BLOCK_HOST_ORDER
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(HASH_BLOCK_DATA_ORDER_ALIGNED)
|
||||
#ifndef HASH_BLOCK_DATA_ORDER
|
||||
#error "HASH_BLOCK_DATA_ORDER must be defined!"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(DATA_ORDER_IS_BIG_ENDIAN)
|
||||
|
||||
#ifndef PEDANTIC
|
||||
# if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
|
||||
# if ((defined(__i386) || defined(__i386__)) && !defined(I386_ONLY)) || \
|
||||
(defined(__x86_64) || defined(__x86_64__))
|
||||
/*
|
||||
* This gives ~30-40% performance improvement in SHA-256 compiled
|
||||
* with gcc [on P4]. Well, first macro to be frank. We can pull
|
||||
* this trick on x86* platforms only, because these CPUs can fetch
|
||||
* unaligned data without raising an exception.
|
||||
*/
|
||||
# define HOST_c2l(c,l) ({ unsigned int r=*((const unsigned int *)(c)); \
|
||||
asm ("bswapl %0":"=r"(r):"0"(r)); \
|
||||
(c)+=4; (l)=r; })
|
||||
# define HOST_l2c(l,c) ({ unsigned int r=(l); \
|
||||
asm ("bswapl %0":"=r"(r):"0"(r)); \
|
||||
*((unsigned int *)(c))=r; (c)+=4; r; })
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HOST_c2l
|
||||
#define HOST_c2l(c,l) (l =(((unsigned long)(*((c)++)))<<24), \
|
||||
l|=(((unsigned long)(*((c)++)))<<16), \
|
||||
l|=(((unsigned long)(*((c)++)))<< 8), \
|
||||
l|=(((unsigned long)(*((c)++))) ), \
|
||||
l)
|
||||
#endif
|
||||
#define HOST_p_c2l(c,l,n) { \
|
||||
switch (n) { \
|
||||
case 0: l =((unsigned long)(*((c)++)))<<24; \
|
||||
case 1: l|=((unsigned long)(*((c)++)))<<16; \
|
||||
case 2: l|=((unsigned long)(*((c)++)))<< 8; \
|
||||
case 3: l|=((unsigned long)(*((c)++))); \
|
||||
} }
|
||||
#define HOST_p_c2l_p(c,l,sc,len) { \
|
||||
switch (sc) { \
|
||||
case 0: l =((unsigned long)(*((c)++)))<<24; \
|
||||
if (--len == 0) break; \
|
||||
case 1: l|=((unsigned long)(*((c)++)))<<16; \
|
||||
if (--len == 0) break; \
|
||||
case 2: l|=((unsigned long)(*((c)++)))<< 8; \
|
||||
} }
|
||||
/* NOTE the pointer is not incremented at the end of this */
|
||||
#define HOST_c2l_p(c,l,n) { \
|
||||
l=0; (c)+=n; \
|
||||
switch (n) { \
|
||||
case 3: l =((unsigned long)(*(--(c))))<< 8; \
|
||||
case 2: l|=((unsigned long)(*(--(c))))<<16; \
|
||||
case 1: l|=((unsigned long)(*(--(c))))<<24; \
|
||||
} }
|
||||
#ifndef HOST_l2c
|
||||
#define HOST_l2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>16)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>> 8)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l) )&0xff), \
|
||||
l)
|
||||
#endif
|
||||
|
||||
#elif defined(DATA_ORDER_IS_LITTLE_ENDIAN)
|
||||
|
||||
#if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)
|
||||
# ifndef B_ENDIAN
|
||||
/* See comment in DATA_ORDER_IS_BIG_ENDIAN section. */
|
||||
# define HOST_c2l(c,l) ((l)=*((const unsigned int *)(c)), (c)+=4, l)
|
||||
# define HOST_l2c(l,c) (*((unsigned int *)(c))=(l), (c)+=4, l)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HOST_c2l
|
||||
#define HOST_c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \
|
||||
l|=(((unsigned long)(*((c)++)))<< 8), \
|
||||
l|=(((unsigned long)(*((c)++)))<<16), \
|
||||
l|=(((unsigned long)(*((c)++)))<<24), \
|
||||
l)
|
||||
#endif
|
||||
#define HOST_p_c2l(c,l,n) { \
|
||||
switch (n) { \
|
||||
case 0: l =((unsigned long)(*((c)++))); \
|
||||
case 1: l|=((unsigned long)(*((c)++)))<< 8; \
|
||||
case 2: l|=((unsigned long)(*((c)++)))<<16; \
|
||||
case 3: l|=((unsigned long)(*((c)++)))<<24; \
|
||||
} }
|
||||
#define HOST_p_c2l_p(c,l,sc,len) { \
|
||||
switch (sc) { \
|
||||
case 0: l =((unsigned long)(*((c)++))); \
|
||||
if (--len == 0) break; \
|
||||
case 1: l|=((unsigned long)(*((c)++)))<< 8; \
|
||||
if (--len == 0) break; \
|
||||
case 2: l|=((unsigned long)(*((c)++)))<<16; \
|
||||
} }
|
||||
/* NOTE the pointer is not incremented at the end of this */
|
||||
#define HOST_c2l_p(c,l,n) { \
|
||||
l=0; (c)+=n; \
|
||||
switch (n) { \
|
||||
case 3: l =((unsigned long)(*(--(c))))<<16; \
|
||||
case 2: l|=((unsigned long)(*(--(c))))<< 8; \
|
||||
case 1: l|=((unsigned long)(*(--(c)))); \
|
||||
} }
|
||||
#ifndef HOST_l2c
|
||||
#define HOST_l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>> 8)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>16)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>24)&0xff), \
|
||||
l)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Time for some action:-)
|
||||
*/
|
||||
|
||||
int HASH_UPDATE (HASH_CTX *c, const void *data_, size_t len)
|
||||
{
|
||||
const unsigned char *data=data_;
|
||||
register HASH_LONG * p;
|
||||
register HASH_LONG l;
|
||||
size_t sw,sc,ew,ec;
|
||||
|
||||
if (len==0) return 1;
|
||||
|
||||
l=(c->Nl+(((HASH_LONG)len)<<3))&0xffffffffUL;
|
||||
/* 95-05-24 eay Fixed a bug with the overflow handling, thanks to
|
||||
* Wei Dai <weidai@eskimo.com> for pointing it out. */
|
||||
if (l < c->Nl) /* overflow */
|
||||
c->Nh++;
|
||||
c->Nh+=(len>>29); /* might cause compiler warning on 16-bit */
|
||||
c->Nl=l;
|
||||
|
||||
if (c->num != 0)
|
||||
{
|
||||
p=c->data;
|
||||
sw=c->num>>2;
|
||||
sc=c->num&0x03;
|
||||
|
||||
if ((c->num+len) >= HASH_CBLOCK)
|
||||
{
|
||||
l=p[sw]; HOST_p_c2l(data,l,sc); p[sw++]=l;
|
||||
for (; sw<HASH_LBLOCK; sw++)
|
||||
{
|
||||
HOST_c2l(data,l); p[sw]=l;
|
||||
}
|
||||
HASH_BLOCK_HOST_ORDER (c,p,1);
|
||||
len-=(HASH_CBLOCK-c->num);
|
||||
c->num=0;
|
||||
/* drop through and do the rest */
|
||||
}
|
||||
else
|
||||
{
|
||||
c->num+=(unsigned int)len;
|
||||
if ((sc+len) < 4) /* ugly, add char's to a word */
|
||||
{
|
||||
l=p[sw]; HOST_p_c2l_p(data,l,sc,len); p[sw]=l;
|
||||
}
|
||||
else
|
||||
{
|
||||
ew=(c->num>>2);
|
||||
ec=(c->num&0x03);
|
||||
if (sc)
|
||||
l=p[sw];
|
||||
HOST_p_c2l(data,l,sc);
|
||||
p[sw++]=l;
|
||||
for (; sw < ew; sw++)
|
||||
{
|
||||
HOST_c2l(data,l); p[sw]=l;
|
||||
}
|
||||
if (ec)
|
||||
{
|
||||
HOST_c2l_p(data,l,ec); p[sw]=l;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
sw=len/HASH_CBLOCK;
|
||||
if (sw > 0)
|
||||
{
|
||||
#if defined(HASH_BLOCK_DATA_ORDER_ALIGNED)
|
||||
/*
|
||||
* Note that HASH_BLOCK_DATA_ORDER_ALIGNED gets defined
|
||||
* only if sizeof(HASH_LONG)==4.
|
||||
*/
|
||||
if ((((size_t)data)%4) == 0)
|
||||
{
|
||||
/* data is properly aligned so that we can cast it: */
|
||||
HASH_BLOCK_DATA_ORDER_ALIGNED (c,(const HASH_LONG *)data,sw);
|
||||
sw*=HASH_CBLOCK;
|
||||
data+=sw;
|
||||
len-=sw;
|
||||
}
|
||||
else
|
||||
#if !defined(HASH_BLOCK_DATA_ORDER)
|
||||
while (sw--)
|
||||
{
|
||||
memcpy (p=c->data,data,HASH_CBLOCK);
|
||||
HASH_BLOCK_DATA_ORDER_ALIGNED(c,p,1);
|
||||
data+=HASH_CBLOCK;
|
||||
len-=HASH_CBLOCK;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#if defined(HASH_BLOCK_DATA_ORDER)
|
||||
{
|
||||
HASH_BLOCK_DATA_ORDER(c,data,sw);
|
||||
sw*=HASH_CBLOCK;
|
||||
data+=sw;
|
||||
len-=sw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (len!=0)
|
||||
{
|
||||
p = c->data;
|
||||
c->num = len;
|
||||
ew=len>>2; /* words to copy */
|
||||
ec=len&0x03;
|
||||
for (; ew; ew--,p++)
|
||||
{
|
||||
HOST_c2l(data,l); *p=l;
|
||||
}
|
||||
HOST_c2l_p(data,l,ec);
|
||||
*p=l;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void HASH_TRANSFORM (HASH_CTX *c, const unsigned char *data)
|
||||
{
|
||||
#if defined(HASH_BLOCK_DATA_ORDER_ALIGNED)
|
||||
if ((((size_t)data)%4) == 0)
|
||||
/* data is properly aligned so that we can cast it: */
|
||||
HASH_BLOCK_DATA_ORDER_ALIGNED (c,(const HASH_LONG *)data,1);
|
||||
else
|
||||
#if !defined(HASH_BLOCK_DATA_ORDER)
|
||||
{
|
||||
memcpy (c->data,data,HASH_CBLOCK);
|
||||
HASH_BLOCK_DATA_ORDER_ALIGNED (c,c->data,1);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#if defined(HASH_BLOCK_DATA_ORDER)
|
||||
HASH_BLOCK_DATA_ORDER (c,data,1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int HASH_FINAL (unsigned char *md, HASH_CTX *c)
|
||||
{
|
||||
register HASH_LONG *p;
|
||||
register unsigned long l;
|
||||
register int i,j;
|
||||
static const unsigned char end[4]={0x80,0x00,0x00,0x00};
|
||||
const unsigned char *cp=end;
|
||||
|
||||
/* c->num should definitly have room for at least one more byte. */
|
||||
p=c->data;
|
||||
i=c->num>>2;
|
||||
j=c->num&0x03;
|
||||
|
||||
#if 0
|
||||
/* purify often complains about the following line as an
|
||||
* Uninitialized Memory Read. While this can be true, the
|
||||
* following p_c2l macro will reset l when that case is true.
|
||||
* This is because j&0x03 contains the number of 'valid' bytes
|
||||
* already in p[i]. If and only if j&0x03 == 0, the UMR will
|
||||
* occur but this is also the only time p_c2l will do
|
||||
* l= *(cp++) instead of l|= *(cp++)
|
||||
* Many thanks to Alex Tang <altitude@cic.net> for pickup this
|
||||
* 'potential bug' */
|
||||
#ifdef PURIFY
|
||||
if (j==0) p[i]=0; /* Yeah, but that's not the way to fix it:-) */
|
||||
#endif
|
||||
l=p[i];
|
||||
#else
|
||||
l = (j==0) ? 0 : p[i];
|
||||
#endif
|
||||
HOST_p_c2l(cp,l,j); p[i++]=l; /* i is the next 'undefined word' */
|
||||
|
||||
if (i>(HASH_LBLOCK-2)) /* save room for Nl and Nh */
|
||||
{
|
||||
if (i<HASH_LBLOCK) p[i]=0;
|
||||
HASH_BLOCK_HOST_ORDER (c,p,1);
|
||||
i=0;
|
||||
}
|
||||
for (; i<(HASH_LBLOCK-2); i++)
|
||||
p[i]=0;
|
||||
|
||||
#if defined(DATA_ORDER_IS_BIG_ENDIAN)
|
||||
p[HASH_LBLOCK-2]=c->Nh;
|
||||
p[HASH_LBLOCK-1]=c->Nl;
|
||||
#elif defined(DATA_ORDER_IS_LITTLE_ENDIAN)
|
||||
p[HASH_LBLOCK-2]=c->Nl;
|
||||
p[HASH_LBLOCK-1]=c->Nh;
|
||||
#endif
|
||||
HASH_BLOCK_HOST_ORDER (c,p,1);
|
||||
|
||||
#ifndef HASH_MAKE_STRING
|
||||
#error "HASH_MAKE_STRING must be defined!"
|
||||
#else
|
||||
HASH_MAKE_STRING(c,md);
|
||||
#endif
|
||||
|
||||
c->num=0;
|
||||
/* clear stuff, HASH_BLOCK may be leaving some stuff on the stack
|
||||
* but I'm not worried :-)
|
||||
OPENSSL_cleanse((void *)c,sizeof(HASH_CTX));
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef MD32_REG_T
|
||||
#define MD32_REG_T long
|
||||
/*
|
||||
* This comment was originaly written for MD5, which is why it
|
||||
* discusses A-D. But it basically applies to all 32-bit digests,
|
||||
* which is why it was moved to common header file.
|
||||
*
|
||||
* In case you wonder why A-D are declared as long and not
|
||||
* as MD5_LONG. Doing so results in slight performance
|
||||
* boost on LP64 architectures. The catch is we don't
|
||||
* really care if 32 MSBs of a 64-bit register get polluted
|
||||
* with eventual overflows as we *save* only 32 LSBs in
|
||||
* *either* case. Now declaring 'em long excuses the compiler
|
||||
* from keeping 32 MSBs zeroed resulting in 13% performance
|
||||
* improvement under SPARC Solaris7/64 and 5% under AlphaLinux.
|
||||
* Well, to be honest it should say that this *prevents*
|
||||
* performance degradation.
|
||||
* <appro@fy.chalmers.se>
|
||||
* Apparently there're LP64 compilers that generate better
|
||||
* code if A-D are declared int. Most notably GCC-x86_64
|
||||
* generates better code.
|
||||
* <appro@fy.chalmers.se>
|
||||
*/
|
||||
#endif
|
116
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/md5.h
Executable file
116
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/md5.h
Executable file
@ -0,0 +1,116 @@
|
||||
/* crypto/md5/md5.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_MD5_H
|
||||
#define HEADER_MD5_H
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef OPENSSL_NO_MD5
|
||||
#error MD5 is disabled.
|
||||
#endif
|
||||
|
||||
/*
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* ! MD5_LONG has to be at least 32 bits wide. If it's wider, then !
|
||||
* ! MD5_LONG_LOG2 has to be defined along. !
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*/
|
||||
|
||||
#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__)
|
||||
#define MD5_LONG unsigned long
|
||||
#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
|
||||
#define MD5_LONG unsigned long
|
||||
#define MD5_LONG_LOG2 3
|
||||
/*
|
||||
* _CRAY note. I could declare short, but I have no idea what impact
|
||||
* does it have on performance on none-T3E machines. I could declare
|
||||
* int, but at least on C90 sizeof(int) can be chosen at compile time.
|
||||
* So I've chosen long...
|
||||
* <appro@fy.chalmers.se>
|
||||
*/
|
||||
#else
|
||||
#define MD5_LONG unsigned int
|
||||
#endif
|
||||
|
||||
#define MD5_CBLOCK 64
|
||||
#define MD5_LBLOCK (MD5_CBLOCK/4)
|
||||
#define MD5_DIGEST_LENGTH 16
|
||||
|
||||
typedef struct MD5state_st
|
||||
{
|
||||
MD5_LONG A,B,C,D;
|
||||
MD5_LONG Nl,Nh;
|
||||
MD5_LONG data[MD5_LBLOCK];
|
||||
unsigned int num;
|
||||
} MD5_CTX;
|
||||
|
||||
int MD5_Init(MD5_CTX *c);
|
||||
int MD5_Update(MD5_CTX *c, const void *data, size_t len);
|
||||
int MD5_Final(unsigned char *md, MD5_CTX *c);
|
||||
unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md);
|
||||
void MD5_Transform(MD5_CTX *c, const unsigned char *b);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
3305
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/obj_mac.h
Executable file
3305
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/obj_mac.h
Executable file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,202 @@
|
||||
/* opensslconf.h */
|
||||
/* WARNING: Generated automatically from opensslconf.h.in by Configure. */
|
||||
|
||||
/* OpenSSL was configured with the following options: */
|
||||
#ifndef OPENSSL_DOING_MAKEDEPEND
|
||||
|
||||
#ifndef OPENSSL_NO_GMP
|
||||
# define OPENSSL_NO_GMP
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_KRB5
|
||||
# define OPENSSL_NO_KRB5
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MDC2
|
||||
# define OPENSSL_NO_MDC2
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC5
|
||||
# define OPENSSL_NO_RC5
|
||||
#endif
|
||||
|
||||
#endif /* OPENSSL_DOING_MAKEDEPEND */
|
||||
#ifndef OPENSSL_NO_DYNAMIC_ENGINE
|
||||
# define OPENSSL_NO_DYNAMIC_ENGINE
|
||||
#endif
|
||||
|
||||
/* The OPENSSL_NO_* macros are also defined as NO_* if the application
|
||||
asks for it. This is a transient feature that is provided for those
|
||||
who haven't had the time to do the appropriate changes in their
|
||||
applications. */
|
||||
#ifdef OPENSSL_ALGORITHM_DEFINES
|
||||
# if defined(OPENSSL_NO_GMP) && !defined(NO_GMP)
|
||||
# define NO_GMP
|
||||
# endif
|
||||
# if defined(OPENSSL_NO_KRB5) && !defined(NO_KRB5)
|
||||
# define NO_KRB5
|
||||
# endif
|
||||
# if defined(OPENSSL_NO_MDC2) && !defined(NO_MDC2)
|
||||
# define NO_MDC2
|
||||
# endif
|
||||
# if defined(OPENSSL_NO_RC5) && !defined(NO_RC5)
|
||||
# define NO_RC5
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* crypto/opensslconf.h.in */
|
||||
|
||||
/* Generate 80386 code? */
|
||||
#undef I386_ONLY
|
||||
|
||||
#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */
|
||||
#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR)
|
||||
#define ENGINESDIR "/usr/local/ssl/lib/engines"
|
||||
#define OPENSSLDIR "/usr/local/ssl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#undef OPENSSL_UNISTD
|
||||
#define OPENSSL_UNISTD <unistd.h>
|
||||
|
||||
#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||
|
||||
#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
|
||||
#define IDEA_INT unsigned int
|
||||
#endif
|
||||
|
||||
#if defined(HEADER_MD2_H) && !defined(MD2_INT)
|
||||
#define MD2_INT unsigned int
|
||||
#endif
|
||||
|
||||
#if defined(HEADER_RC2_H) && !defined(RC2_INT)
|
||||
/* I need to put in a mod for the alpha - eay */
|
||||
#define RC2_INT unsigned int
|
||||
#endif
|
||||
|
||||
#if defined(HEADER_RC4_H)
|
||||
#if !defined(RC4_INT)
|
||||
/* using int types make the structure larger but make the code faster
|
||||
* on most boxes I have tested - up to %20 faster. */
|
||||
/*
|
||||
* I don't know what does "most" mean, but declaring "int" is a must on:
|
||||
* - Intel P6 because partial register stalls are very expensive;
|
||||
* - elder Alpha because it lacks byte load/store instructions;
|
||||
*/
|
||||
#define RC4_INT unsigned int
|
||||
#endif
|
||||
#if !defined(RC4_CHUNK)
|
||||
/*
|
||||
* This enables code handling data aligned at natural CPU word
|
||||
* boundary. See crypto/rc4/rc4_enc.c for further details.
|
||||
*/
|
||||
#undef RC4_CHUNK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
|
||||
/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
|
||||
* %20 speed up (longs are 8 bytes, int's are 4). */
|
||||
#ifndef DES_LONG
|
||||
#define DES_LONG unsigned long
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
|
||||
#define CONFIG_HEADER_BN_H
|
||||
#undef BN_LLONG
|
||||
|
||||
/* Should we define BN_DIV2W here? */
|
||||
|
||||
/* Only one for the following should be defined */
|
||||
/* The prime number generation stuff may not work when
|
||||
* EIGHT_BIT but I don't care since I've only used this mode
|
||||
* for debuging the bignum libraries */
|
||||
#undef SIXTY_FOUR_BIT_LONG
|
||||
#undef SIXTY_FOUR_BIT
|
||||
#define THIRTY_TWO_BIT
|
||||
#undef SIXTEEN_BIT
|
||||
#undef EIGHT_BIT
|
||||
#endif
|
||||
|
||||
#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
|
||||
#define CONFIG_HEADER_RC4_LOCL_H
|
||||
/* if this is defined data[i] is used instead of *data, this is a %20
|
||||
* speedup on x86 */
|
||||
#undef RC4_INDEX
|
||||
#endif
|
||||
|
||||
#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
|
||||
#define CONFIG_HEADER_BF_LOCL_H
|
||||
#undef BF_PTR
|
||||
#endif /* HEADER_BF_LOCL_H */
|
||||
|
||||
#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
|
||||
#define CONFIG_HEADER_DES_LOCL_H
|
||||
#ifndef DES_DEFAULT_OPTIONS
|
||||
/* the following is tweaked from a config script, that is why it is a
|
||||
* protected undef/define */
|
||||
#ifndef DES_PTR
|
||||
#undef DES_PTR
|
||||
#endif
|
||||
|
||||
/* This helps C compiler generate the correct code for multiple functional
|
||||
* units. It reduces register dependancies at the expense of 2 more
|
||||
* registers */
|
||||
#ifndef DES_RISC1
|
||||
#undef DES_RISC1
|
||||
#endif
|
||||
|
||||
#ifndef DES_RISC2
|
||||
#undef DES_RISC2
|
||||
#endif
|
||||
|
||||
#if defined(DES_RISC1) && defined(DES_RISC2)
|
||||
YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
|
||||
#endif
|
||||
|
||||
/* Unroll the inner loop, this sometimes helps, sometimes hinders.
|
||||
* Very mucy CPU dependant */
|
||||
#ifndef DES_UNROLL
|
||||
#undef DES_UNROLL
|
||||
#endif
|
||||
|
||||
/* These default values were supplied by
|
||||
* Peter Gutman <pgut001@cs.auckland.ac.nz>
|
||||
* They are only used if nothing else has been defined */
|
||||
#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
|
||||
/* Special defines which change the way the code is built depending on the
|
||||
CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
|
||||
even newer MIPS CPU's, but at the moment one size fits all for
|
||||
optimization options. Older Sparc's work better with only UNROLL, but
|
||||
there's no way to tell at compile time what it is you're running on */
|
||||
|
||||
#if defined( sun ) /* Newer Sparc's */
|
||||
# define DES_PTR
|
||||
# define DES_RISC1
|
||||
# define DES_UNROLL
|
||||
#elif defined( __ultrix ) /* Older MIPS */
|
||||
# define DES_PTR
|
||||
# define DES_RISC2
|
||||
# define DES_UNROLL
|
||||
#elif defined( __osf1__ ) /* Alpha */
|
||||
# define DES_PTR
|
||||
# define DES_RISC2
|
||||
#elif defined ( _AIX ) /* RS6000 */
|
||||
/* Unknown */
|
||||
#elif defined( __hpux ) /* HP-PA */
|
||||
/* Unknown */
|
||||
#elif defined( __aux ) /* 68K */
|
||||
/* Unknown */
|
||||
#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
|
||||
# define DES_UNROLL
|
||||
#elif defined( __sgi ) /* Newer MIPS */
|
||||
# define DES_PTR
|
||||
# define DES_RISC2
|
||||
# define DES_UNROLL
|
||||
#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
|
||||
# define DES_PTR
|
||||
# define DES_RISC1
|
||||
# define DES_UNROLL
|
||||
#endif /* Systems-specific speed defines */
|
||||
#endif
|
||||
|
||||
#endif /* DES_DEFAULT_OPTIONS */
|
||||
#endif /* HEADER_DES_LOCL_H */
|
@ -0,0 +1,89 @@
|
||||
#ifndef HEADER_OPENSSLV_H
|
||||
#define HEADER_OPENSSLV_H
|
||||
|
||||
/* Numeric release version identifier:
|
||||
* MNNFFPPS: major minor fix patch status
|
||||
* The status nibble has one of the values 0 for development, 1 to e for betas
|
||||
* 1 to 14, and f for release. The patch level is exactly that.
|
||||
* For example:
|
||||
* 0.9.3-dev 0x00903000
|
||||
* 0.9.3-beta1 0x00903001
|
||||
* 0.9.3-beta2-dev 0x00903002
|
||||
* 0.9.3-beta2 0x00903002 (same as ...beta2-dev)
|
||||
* 0.9.3 0x0090300f
|
||||
* 0.9.3a 0x0090301f
|
||||
* 0.9.4 0x0090400f
|
||||
* 1.2.3z 0x102031af
|
||||
*
|
||||
* For continuity reasons (because 0.9.5 is already out, and is coded
|
||||
* 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level
|
||||
* part is slightly different, by setting the highest bit. This means
|
||||
* that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start
|
||||
* with 0x0090600S...
|
||||
*
|
||||
* (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.)
|
||||
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
|
||||
* major minor fix final patch/beta)
|
||||
*/
|
||||
#define OPENSSL_VERSION_NUMBER 0x0090802fL
|
||||
#ifdef OPENSSL_FIPS
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8b-fips 04 May 2006"
|
||||
#else
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8b 04 May 2006"
|
||||
#endif
|
||||
#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
|
||||
|
||||
|
||||
/* The macros below are to be used for shared library (.so, .dll, ...)
|
||||
* versioning. That kind of versioning works a bit differently between
|
||||
* operating systems. The most usual scheme is to set a major and a minor
|
||||
* number, and have the runtime loader check that the major number is equal
|
||||
* to what it was at application link time, while the minor number has to
|
||||
* be greater or equal to what it was at application link time. With this
|
||||
* scheme, the version number is usually part of the file name, like this:
|
||||
*
|
||||
* libcrypto.so.0.9
|
||||
*
|
||||
* Some unixen also make a softlink with the major verson number only:
|
||||
*
|
||||
* libcrypto.so.0
|
||||
*
|
||||
* On Tru64 and IRIX 6.x it works a little bit differently. There, the
|
||||
* shared library version is stored in the file, and is actually a series
|
||||
* of versions, separated by colons. The rightmost version present in the
|
||||
* library when linking an application is stored in the application to be
|
||||
* matched at run time. When the application is run, a check is done to
|
||||
* see if the library version stored in the application matches any of the
|
||||
* versions in the version string of the library itself.
|
||||
* This version string can be constructed in any way, depending on what
|
||||
* kind of matching is desired. However, to implement the same scheme as
|
||||
* the one used in the other unixen, all compatible versions, from lowest
|
||||
* to highest, should be part of the string. Consecutive builds would
|
||||
* give the following versions strings:
|
||||
*
|
||||
* 3.0
|
||||
* 3.0:3.1
|
||||
* 3.0:3.1:3.2
|
||||
* 4.0
|
||||
* 4.0:4.1
|
||||
*
|
||||
* Notice how version 4 is completely incompatible with version, and
|
||||
* therefore give the breach you can see.
|
||||
*
|
||||
* There may be other schemes as well that I haven't yet discovered.
|
||||
*
|
||||
* So, here's the way it works here: first of all, the library version
|
||||
* number doesn't need at all to match the overall OpenSSL version.
|
||||
* However, it's nice and more understandable if it actually does.
|
||||
* The current library version is stored in the macro SHLIB_VERSION_NUMBER,
|
||||
* which is just a piece of text in the format "M.m.e" (Major, minor, edit).
|
||||
* For the sake of Tru64, IRIX, and any other OS that behaves in similar ways,
|
||||
* we need to keep a history of version numbers, which is done in the
|
||||
* macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and
|
||||
* should only keep the versions that are binary compatible with the current.
|
||||
*/
|
||||
#define SHLIB_VERSION_HISTORY ""
|
||||
#define SHLIB_VERSION_NUMBER "0.9.8"
|
||||
|
||||
|
||||
#endif /* HEADER_OPENSSLV_H */
|
186
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/ossl_typ.h
Executable file
186
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/ossl_typ.h
Executable file
@ -0,0 +1,186 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2001 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).
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_OPENSSL_TYPES_H
|
||||
#define HEADER_OPENSSL_TYPES_H
|
||||
|
||||
/*Begin: add project definitions , 17Aug2006, Chris */
|
||||
#include "ProjectDef.h"
|
||||
/*End: add project definitions , 17Aug2006, Chris */
|
||||
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#ifdef NO_ASN1_TYPEDEFS
|
||||
#define ASN1_INTEGER ASN1_STRING
|
||||
#define ASN1_ENUMERATED ASN1_STRING
|
||||
#define ASN1_BIT_STRING ASN1_STRING
|
||||
#define ASN1_OCTET_STRING ASN1_STRING
|
||||
#define ASN1_PRINTABLESTRING ASN1_STRING
|
||||
#define ASN1_T61STRING ASN1_STRING
|
||||
#define ASN1_IA5STRING ASN1_STRING
|
||||
#define ASN1_UTCTIME ASN1_STRING
|
||||
#define ASN1_GENERALIZEDTIME ASN1_STRING
|
||||
#define ASN1_TIME ASN1_STRING
|
||||
#define ASN1_GENERALSTRING ASN1_STRING
|
||||
#define ASN1_UNIVERSALSTRING ASN1_STRING
|
||||
#define ASN1_BMPSTRING ASN1_STRING
|
||||
#define ASN1_VISIBLESTRING ASN1_STRING
|
||||
#define ASN1_UTF8STRING ASN1_STRING
|
||||
#define ASN1_BOOLEAN int
|
||||
#define ASN1_NULL int
|
||||
#else
|
||||
typedef struct asn1_string_st ASN1_INTEGER;
|
||||
typedef struct asn1_string_st ASN1_ENUMERATED;
|
||||
typedef struct asn1_string_st ASN1_BIT_STRING;
|
||||
typedef struct asn1_string_st ASN1_OCTET_STRING;
|
||||
typedef struct asn1_string_st ASN1_PRINTABLESTRING;
|
||||
typedef struct asn1_string_st ASN1_T61STRING;
|
||||
typedef struct asn1_string_st ASN1_IA5STRING;
|
||||
typedef struct asn1_string_st ASN1_GENERALSTRING;
|
||||
typedef struct asn1_string_st ASN1_UNIVERSALSTRING;
|
||||
typedef struct asn1_string_st ASN1_BMPSTRING;
|
||||
typedef struct asn1_string_st ASN1_UTCTIME;
|
||||
typedef struct asn1_string_st ASN1_TIME;
|
||||
typedef struct asn1_string_st ASN1_GENERALIZEDTIME;
|
||||
typedef struct asn1_string_st ASN1_VISIBLESTRING;
|
||||
typedef struct asn1_string_st ASN1_UTF8STRING;
|
||||
typedef int ASN1_BOOLEAN;
|
||||
typedef int ASN1_NULL;
|
||||
#endif
|
||||
|
||||
#ifdef OPENSSL_SYS_WIN32
|
||||
#undef X509_NAME
|
||||
#undef X509_CERT_PAIR
|
||||
#undef PKCS7_ISSUER_AND_SERIAL
|
||||
#endif
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
#ifdef BIGNUM
|
||||
#undef BIGNUM
|
||||
#endif
|
||||
typedef struct bignum_st BIGNUM;
|
||||
typedef struct bignum_ctx BN_CTX;
|
||||
typedef struct bn_blinding_st BN_BLINDING;
|
||||
typedef struct bn_mont_ctx_st BN_MONT_CTX;
|
||||
typedef struct bn_recp_ctx_st BN_RECP_CTX;
|
||||
typedef struct bn_gencb_st BN_GENCB;
|
||||
|
||||
typedef struct buf_mem_st BUF_MEM;
|
||||
|
||||
typedef struct evp_cipher_st EVP_CIPHER;
|
||||
typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;
|
||||
typedef struct env_md_st EVP_MD;
|
||||
typedef struct env_md_ctx_st EVP_MD_CTX;
|
||||
typedef struct evp_pkey_st EVP_PKEY;
|
||||
|
||||
typedef struct dh_st DH;
|
||||
typedef struct dh_method DH_METHOD;
|
||||
|
||||
typedef struct dsa_st DSA;
|
||||
typedef struct dsa_method DSA_METHOD;
|
||||
|
||||
typedef struct rsa_st RSA;
|
||||
typedef struct rsa_meth_st RSA_METHOD;
|
||||
|
||||
typedef struct rand_meth_st RAND_METHOD;
|
||||
|
||||
typedef struct ecdh_method ECDH_METHOD;
|
||||
typedef struct ecdsa_method ECDSA_METHOD;
|
||||
|
||||
typedef struct x509_st X509;
|
||||
typedef struct X509_algor_st X509_ALGOR;
|
||||
typedef struct X509_crl_st X509_CRL;
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
typedef struct X509_name_st X509_NAME;
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
typedef struct x509_store_st X509_STORE;
|
||||
typedef struct x509_store_ctx_st X509_STORE_CTX;
|
||||
|
||||
typedef struct v3_ext_ctx X509V3_CTX;
|
||||
typedef struct conf_st CONF;
|
||||
|
||||
typedef struct store_st STORE;
|
||||
typedef struct store_method_st STORE_METHOD;
|
||||
|
||||
typedef struct ui_st UI;
|
||||
typedef struct ui_method_st UI_METHOD;
|
||||
|
||||
typedef struct st_ERR_FNS ERR_FNS;
|
||||
|
||||
typedef struct engine_st ENGINE;
|
||||
|
||||
typedef struct X509_POLICY_NODE_st X509_POLICY_NODE;
|
||||
typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL;
|
||||
typedef struct X509_POLICY_TREE_st X509_POLICY_TREE;
|
||||
typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE;
|
||||
|
||||
/* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */
|
||||
#define DECLARE_PKCS12_STACK_OF(type) /* Nothing */
|
||||
#define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */
|
||||
|
||||
typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
|
||||
/* Callback types for crypto.h */
|
||||
typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp);
|
||||
typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp);
|
||||
typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
|
||||
int idx, long argl, void *argp);
|
||||
|
||||
#endif /* def HEADER_OPENSSL_TYPES_H */
|
142
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/rand.h
Executable file
142
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/rand.h
Executable file
@ -0,0 +1,142 @@
|
||||
/* crypto/rand/rand.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_RAND_H
|
||||
#define HEADER_RAND_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <openssl/ossl_typ.h>
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
|
||||
#if defined(OPENSSL_SYS_WINDOWS)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_FIPS)
|
||||
#define FIPS_RAND_SIZE_T size_t
|
||||
#endif
|
||||
|
||||
/* Already defined in ossl_typ.h */
|
||||
/* typedef struct rand_meth_st RAND_METHOD; */
|
||||
|
||||
struct rand_meth_st
|
||||
{
|
||||
void (*seed)(const void *buf, int num);
|
||||
int (*bytes)(unsigned char *buf, int num);
|
||||
void (*cleanup)(void);
|
||||
void (*add)(const void *buf, int num, int entropy);
|
||||
int (*pseudorand)(unsigned char *buf, int num);
|
||||
int (*status)(void);
|
||||
};
|
||||
|
||||
#ifdef BN_DEBUG
|
||||
extern int rand_predictable;
|
||||
#endif
|
||||
|
||||
int RAND_set_rand_method(const RAND_METHOD *meth);
|
||||
const RAND_METHOD *RAND_get_rand_method(void);
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
int RAND_set_rand_engine(ENGINE *engine);
|
||||
#endif
|
||||
RAND_METHOD *RAND_SSLeay(void);
|
||||
void RAND_cleanup(void );
|
||||
int RAND_bytes(unsigned char *buf,int num);
|
||||
int RAND_pseudo_bytes(unsigned char *buf,int num);
|
||||
void RAND_seed(const void *buf,int num);
|
||||
void RAND_add(const void *buf,int num,int entropy);
|
||||
int RAND_load_file(const char *file,long max_bytes);
|
||||
int RAND_write_file(const char *file);
|
||||
const char *RAND_file_name(char *file,size_t num);
|
||||
int RAND_status(void);
|
||||
int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
|
||||
int RAND_egd(const char *path);
|
||||
int RAND_egd_bytes(const char *path,int bytes);
|
||||
int RAND_poll(void);
|
||||
|
||||
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
|
||||
|
||||
void RAND_screen(void);
|
||||
int RAND_event(UINT, WPARAM, LPARAM);
|
||||
|
||||
#endif
|
||||
|
||||
/* 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_RAND_strings(void);
|
||||
|
||||
/* Error codes for the RAND functions. */
|
||||
|
||||
/* Function codes. */
|
||||
#define RAND_F_RAND_GET_RAND_METHOD 101
|
||||
#define RAND_F_SSLEAY_RAND_BYTES 100
|
||||
|
||||
/* Reason codes. */
|
||||
#define RAND_R_PRNG_NOT_SEEDED 100
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
158
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/rand_lcl.h
Executable file
158
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/rand_lcl.h
Executable file
@ -0,0 +1,158 @@
|
||||
/* crypto/rand/rand_lcl.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2000 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).
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_RAND_LCL_H
|
||||
#define HEADER_RAND_LCL_H
|
||||
|
||||
#define ENTROPY_NEEDED 32 /* require 256 bits = 32 bytes of randomness */
|
||||
|
||||
|
||||
#if !defined(USE_MD5_RAND) && !defined(USE_SHA1_RAND) && !defined(USE_MDC2_RAND) && !defined(USE_MD2_RAND)
|
||||
#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
|
||||
#define USE_SHA1_RAND
|
||||
#elif !defined(OPENSSL_NO_MD5)
|
||||
#define USE_MD5_RAND
|
||||
#elif !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DES)
|
||||
#define USE_MDC2_RAND
|
||||
#elif !defined(OPENSSL_NO_MD2)
|
||||
#define USE_MD2_RAND
|
||||
#else
|
||||
#error No message digest algorithm available
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <openssl/evp.h>
|
||||
#define MD_Update(a,b,c) EVP_DigestUpdate(a,b,c)
|
||||
#define MD_Final(a,b) EVP_DigestFinal_ex(a,b,NULL)
|
||||
#if defined(USE_MD5_RAND)
|
||||
#include <openssl/md5.h>
|
||||
#define MD_DIGEST_LENGTH MD5_DIGEST_LENGTH
|
||||
#define MD_Init(a) EVP_DigestInit_ex(a,EVP_md5(), NULL)
|
||||
#define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_md5(), NULL)
|
||||
#elif defined(USE_SHA1_RAND)
|
||||
#include <openssl/sha.h>
|
||||
#define MD_DIGEST_LENGTH SHA_DIGEST_LENGTH
|
||||
#define MD_Init(a) EVP_DigestInit_ex(a,EVP_sha1(), NULL)
|
||||
#define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_sha1(), NULL)
|
||||
#elif defined(USE_MDC2_RAND)
|
||||
#include <openssl/mdc2.h>
|
||||
#define MD_DIGEST_LENGTH MDC2_DIGEST_LENGTH
|
||||
#define MD_Init(a) EVP_DigestInit_ex(a,EVP_mdc2(), NULL)
|
||||
#define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_mdc2(), NULL)
|
||||
#elif defined(USE_MD2_RAND)
|
||||
#include <openssl/md2.h>
|
||||
#define MD_DIGEST_LENGTH MD2_DIGEST_LENGTH
|
||||
#define MD_Init(a) EVP_DigestInit_ex(a,EVP_md2(), NULL)
|
||||
#define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_md2(), NULL)
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
1574
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/safestack.h
Executable file
1574
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/safestack.h
Executable file
File diff suppressed because it is too large
Load Diff
200
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/sha.h
Executable file
200
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/sha.h
Executable file
@ -0,0 +1,200 @@
|
||||
/* crypto/sha/sha.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_SHA_H
|
||||
#define HEADER_SHA_H
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1))
|
||||
#error SHA is disabled.
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_FIPS)
|
||||
#define FIPS_SHA_SIZE_T size_t
|
||||
#endif
|
||||
|
||||
/*
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* ! SHA_LONG has to be at least 32 bits wide. If it's wider, then !
|
||||
* ! SHA_LONG_LOG2 has to be defined along. !
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*/
|
||||
|
||||
#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__)
|
||||
#define SHA_LONG unsigned int
|
||||
#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
|
||||
#define SHA_LONG unsigned int
|
||||
#define SHA_LONG_LOG2 3
|
||||
#else
|
||||
#define SHA_LONG unsigned int
|
||||
#endif
|
||||
|
||||
#define SHA_LBLOCK 16
|
||||
#define SHA_CBLOCK (SHA_LBLOCK*4) /* SHA treats input data as a
|
||||
* contiguous array of 32 bit
|
||||
* wide big-endian values. */
|
||||
#define SHA_LAST_BLOCK (SHA_CBLOCK-8)
|
||||
#define SHA_DIGEST_LENGTH 20
|
||||
|
||||
typedef struct SHAstate_st
|
||||
{
|
||||
SHA_LONG h0,h1,h2,h3,h4;
|
||||
SHA_LONG Nl,Nh;
|
||||
SHA_LONG data[SHA_LBLOCK];
|
||||
unsigned int num;
|
||||
} SHA_CTX;
|
||||
|
||||
#ifndef OPENSSL_NO_SHA0
|
||||
int SHA_Init(SHA_CTX *c);
|
||||
int SHA_Update(SHA_CTX *c, const void *data, size_t len);
|
||||
int SHA_Final(unsigned char *md, SHA_CTX *c);
|
||||
unsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md);
|
||||
void SHA_Transform(SHA_CTX *c, const unsigned char *data);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SHA1
|
||||
int SHA1_Init(SHA_CTX *c);
|
||||
int SHA1_Update(SHA_CTX *c, const void *data, size_t len);
|
||||
int SHA1_Final(unsigned char *md, SHA_CTX *c);
|
||||
unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);
|
||||
void SHA1_Transform(SHA_CTX *c, const unsigned char *data);
|
||||
#endif
|
||||
|
||||
#define SHA256_CBLOCK (SHA_LBLOCK*4) /* SHA-256 treats input data as a
|
||||
* contiguous array of 32 bit
|
||||
* wide big-endian values. */
|
||||
#define SHA224_DIGEST_LENGTH 28
|
||||
#define SHA256_DIGEST_LENGTH 32
|
||||
|
||||
typedef struct SHA256state_st
|
||||
{
|
||||
SHA_LONG h[8];
|
||||
SHA_LONG Nl,Nh;
|
||||
SHA_LONG data[SHA_LBLOCK];
|
||||
unsigned int num,md_len;
|
||||
} SHA256_CTX;
|
||||
|
||||
#ifndef OPENSSL_NO_SHA256
|
||||
int SHA224_Init(SHA256_CTX *c);
|
||||
int SHA224_Update(SHA256_CTX *c, const void *data, size_t len);
|
||||
int SHA224_Final(unsigned char *md, SHA256_CTX *c);
|
||||
unsigned char *SHA224(const unsigned char *d, size_t n,unsigned char *md);
|
||||
int SHA256_Init(SHA256_CTX *c);
|
||||
int SHA256_Update(SHA256_CTX *c, const void *data, size_t len);
|
||||
int SHA256_Final(unsigned char *md, SHA256_CTX *c);
|
||||
unsigned char *SHA256(const unsigned char *d, size_t n,unsigned char *md);
|
||||
void SHA256_Transform(SHA256_CTX *c, const unsigned char *data);
|
||||
#endif
|
||||
|
||||
#define SHA384_DIGEST_LENGTH 48
|
||||
#define SHA512_DIGEST_LENGTH 64
|
||||
|
||||
#ifndef OPENSSL_NO_SHA512
|
||||
/*
|
||||
* Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64
|
||||
* being exactly 64-bit wide. See Implementation Notes in sha512.c
|
||||
* for further details.
|
||||
*/
|
||||
#define SHA512_CBLOCK (SHA_LBLOCK*8) /* SHA-512 treats input data as a
|
||||
* contiguous array of 64 bit
|
||||
* wide big-endian values. */
|
||||
#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
|
||||
#define SHA_LONG64 unsigned __int64
|
||||
#define U64(C) C##UI64
|
||||
#elif defined(__arch64__)
|
||||
#define SHA_LONG64 unsigned long
|
||||
#define U64(C) C##UL
|
||||
#else
|
||||
#define SHA_LONG64 unsigned long long
|
||||
#define U64(C) C##ULL
|
||||
#endif
|
||||
|
||||
typedef struct SHA512state_st
|
||||
{
|
||||
SHA_LONG64 h[8];
|
||||
SHA_LONG64 Nl,Nh;
|
||||
union {
|
||||
SHA_LONG64 d[SHA_LBLOCK];
|
||||
unsigned char p[SHA512_CBLOCK];
|
||||
} u;
|
||||
unsigned int num,md_len;
|
||||
} SHA512_CTX;
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_SHA512
|
||||
int SHA384_Init(SHA512_CTX *c);
|
||||
int SHA384_Update(SHA512_CTX *c, const void *data, size_t len);
|
||||
int SHA384_Final(unsigned char *md, SHA512_CTX *c);
|
||||
unsigned char *SHA384(const unsigned char *d, size_t n,unsigned char *md);
|
||||
int SHA512_Init(SHA512_CTX *c);
|
||||
int SHA512_Update(SHA512_CTX *c, const void *data, size_t len);
|
||||
int SHA512_Final(unsigned char *md, SHA512_CTX *c);
|
||||
unsigned char *SHA512(const unsigned char *d, size_t n,unsigned char *md);
|
||||
void SHA512_Transform(SHA512_CTX *c, const unsigned char *data);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
610
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/sha_locl.h
Executable file
610
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/sha_locl.h
Executable file
@ -0,0 +1,610 @@
|
||||
/* crypto/sha/sha_locl.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#include <openssl/opensslconf.h>
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
#include <openssl/sha.h>
|
||||
|
||||
#ifndef SHA_LONG_LOG2
|
||||
#define SHA_LONG_LOG2 2 /* default to 32 bits */
|
||||
#endif
|
||||
|
||||
#define DATA_ORDER_IS_BIG_ENDIAN
|
||||
|
||||
#define HASH_LONG SHA_LONG
|
||||
#define HASH_LONG_LOG2 SHA_LONG_LOG2
|
||||
#define HASH_CTX SHA_CTX
|
||||
#define HASH_CBLOCK SHA_CBLOCK
|
||||
#define HASH_LBLOCK SHA_LBLOCK
|
||||
#define HASH_MAKE_STRING(c,s) do { \
|
||||
unsigned long ll; \
|
||||
ll=(c)->h0; HOST_l2c(ll,(s)); \
|
||||
ll=(c)->h1; HOST_l2c(ll,(s)); \
|
||||
ll=(c)->h2; HOST_l2c(ll,(s)); \
|
||||
ll=(c)->h3; HOST_l2c(ll,(s)); \
|
||||
ll=(c)->h4; HOST_l2c(ll,(s)); \
|
||||
} while (0)
|
||||
|
||||
#if defined(SHA_0)
|
||||
|
||||
# define HASH_UPDATE SHA_Update
|
||||
# define HASH_TRANSFORM SHA_Transform
|
||||
# define HASH_FINAL SHA_Final
|
||||
# define HASH_INIT SHA_Init
|
||||
# define HASH_BLOCK_HOST_ORDER sha_block_host_order
|
||||
# define HASH_BLOCK_DATA_ORDER sha_block_data_order
|
||||
# define Xupdate(a,ix,ia,ib,ic,id) (ix=(a)=(ia^ib^ic^id))
|
||||
|
||||
void sha_block_host_order (SHA_CTX *c, const void *p,size_t num);
|
||||
void sha_block_data_order (SHA_CTX *c, const void *p,size_t num);
|
||||
|
||||
#elif defined(SHA_1)
|
||||
|
||||
# define HASH_UPDATE SHA1_Update
|
||||
# define HASH_TRANSFORM SHA1_Transform
|
||||
# define HASH_FINAL SHA1_Final
|
||||
# define HASH_INIT SHA1_Init
|
||||
# define HASH_BLOCK_HOST_ORDER sha1_block_host_order
|
||||
# define HASH_BLOCK_DATA_ORDER sha1_block_data_order
|
||||
# if defined(__MWERKS__) && defined(__MC68K__)
|
||||
/* Metrowerks for Motorola fails otherwise:-( <appro@fy.chalmers.se> */
|
||||
# define Xupdate(a,ix,ia,ib,ic,id) do { (a)=(ia^ib^ic^id); \
|
||||
ix=(a)=ROTATE((a),1); \
|
||||
} while (0)
|
||||
# else
|
||||
# define Xupdate(a,ix,ia,ib,ic,id) ( (a)=(ia^ib^ic^id), \
|
||||
ix=(a)=ROTATE((a),1) \
|
||||
)
|
||||
# endif
|
||||
|
||||
# ifdef SHA1_ASM
|
||||
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
|
||||
# if !defined(B_ENDIAN)
|
||||
# define sha1_block_host_order sha1_block_asm_host_order
|
||||
# define DONT_IMPLEMENT_BLOCK_HOST_ORDER
|
||||
# define sha1_block_data_order sha1_block_asm_data_order
|
||||
# define DONT_IMPLEMENT_BLOCK_DATA_ORDER
|
||||
# define HASH_BLOCK_DATA_ORDER_ALIGNED sha1_block_asm_data_order
|
||||
# endif
|
||||
# elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
|
||||
# define sha1_block_host_order sha1_block_asm_host_order
|
||||
# define DONT_IMPLEMENT_BLOCK_HOST_ORDER
|
||||
# define sha1_block_data_order sha1_block_asm_data_order
|
||||
# define DONT_IMPLEMENT_BLOCK_DATA_ORDER
|
||||
# endif
|
||||
# endif
|
||||
void sha1_block_host_order (SHA_CTX *c, const void *p,size_t num);
|
||||
void sha1_block_data_order (SHA_CTX *c, const void *p,size_t num);
|
||||
|
||||
#else
|
||||
# error "Either SHA_0 or SHA_1 must be defined."
|
||||
#endif
|
||||
|
||||
#include "md32_common.h"
|
||||
|
||||
#define INIT_DATA_h0 0x67452301UL
|
||||
#define INIT_DATA_h1 0xefcdab89UL
|
||||
#define INIT_DATA_h2 0x98badcfeUL
|
||||
#define INIT_DATA_h3 0x10325476UL
|
||||
#define INIT_DATA_h4 0xc3d2e1f0UL
|
||||
|
||||
int HASH_INIT (SHA_CTX *c)
|
||||
{
|
||||
c->h0=INIT_DATA_h0;
|
||||
c->h1=INIT_DATA_h1;
|
||||
c->h2=INIT_DATA_h2;
|
||||
c->h3=INIT_DATA_h3;
|
||||
c->h4=INIT_DATA_h4;
|
||||
c->Nl=0;
|
||||
c->Nh=0;
|
||||
c->num=0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define K_00_19 0x5a827999UL
|
||||
#define K_20_39 0x6ed9eba1UL
|
||||
#define K_40_59 0x8f1bbcdcUL
|
||||
#define K_60_79 0xca62c1d6UL
|
||||
|
||||
/* As pointed out by Wei Dai <weidai@eskimo.com>, F() below can be
|
||||
* simplified to the code in F_00_19. Wei attributes these optimisations
|
||||
* to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel.
|
||||
* #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
|
||||
* I've just become aware of another tweak to be made, again from Wei Dai,
|
||||
* in F_40_59, (x&a)|(y&a) -> (x|y)&a
|
||||
*/
|
||||
#define F_00_19(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
|
||||
#define F_20_39(b,c,d) ((b) ^ (c) ^ (d))
|
||||
#define F_40_59(b,c,d) (((b) & (c)) | (((b)|(c)) & (d)))
|
||||
#define F_60_79(b,c,d) F_20_39(b,c,d)
|
||||
|
||||
#ifndef OPENSSL_SMALL_FOOTPRINT
|
||||
|
||||
#define BODY_00_15(i,a,b,c,d,e,f,xi) \
|
||||
(f)=xi+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
|
||||
(b)=ROTATE((b),30);
|
||||
|
||||
#define BODY_16_19(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \
|
||||
Xupdate(f,xi,xa,xb,xc,xd); \
|
||||
(f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
|
||||
(b)=ROTATE((b),30);
|
||||
|
||||
#define BODY_20_31(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \
|
||||
Xupdate(f,xi,xa,xb,xc,xd); \
|
||||
(f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \
|
||||
(b)=ROTATE((b),30);
|
||||
|
||||
#define BODY_32_39(i,a,b,c,d,e,f,xa,xb,xc,xd) \
|
||||
Xupdate(f,xa,xa,xb,xc,xd); \
|
||||
(f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \
|
||||
(b)=ROTATE((b),30);
|
||||
|
||||
#define BODY_40_59(i,a,b,c,d,e,f,xa,xb,xc,xd) \
|
||||
Xupdate(f,xa,xa,xb,xc,xd); \
|
||||
(f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \
|
||||
(b)=ROTATE((b),30);
|
||||
|
||||
#define BODY_60_79(i,a,b,c,d,e,f,xa,xb,xc,xd) \
|
||||
Xupdate(f,xa,xa,xb,xc,xd); \
|
||||
(f)=xa+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \
|
||||
(b)=ROTATE((b),30);
|
||||
|
||||
#ifdef X
|
||||
#undef X
|
||||
#endif
|
||||
#ifndef MD32_XARRAY
|
||||
/*
|
||||
* Originally X was an array. As it's automatic it's natural
|
||||
* to expect RISC compiler to accomodate at least part of it in
|
||||
* the register bank, isn't it? Unfortunately not all compilers
|
||||
* "find" this expectation reasonable:-( On order to make such
|
||||
* compilers generate better code I replace X[] with a bunch of
|
||||
* X0, X1, etc. See the function body below...
|
||||
* <appro@fy.chalmers.se>
|
||||
*/
|
||||
# define X(i) XX##i
|
||||
#else
|
||||
/*
|
||||
* However! Some compilers (most notably HP C) get overwhelmed by
|
||||
* that many local variables so that we have to have the way to
|
||||
* fall down to the original behavior.
|
||||
*/
|
||||
# define X(i) XX[i]
|
||||
#endif
|
||||
|
||||
#ifndef DONT_IMPLEMENT_BLOCK_HOST_ORDER
|
||||
void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, size_t num)
|
||||
{
|
||||
const SHA_LONG *W=d;
|
||||
register unsigned MD32_REG_T A,B,C,D,E,T;
|
||||
#ifndef MD32_XARRAY
|
||||
unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
|
||||
XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
|
||||
#else
|
||||
SHA_LONG XX[16];
|
||||
#endif
|
||||
|
||||
A=c->h0;
|
||||
B=c->h1;
|
||||
C=c->h2;
|
||||
D=c->h3;
|
||||
E=c->h4;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
BODY_00_15( 0,A,B,C,D,E,T,W[ 0]);
|
||||
BODY_00_15( 1,T,A,B,C,D,E,W[ 1]);
|
||||
BODY_00_15( 2,E,T,A,B,C,D,W[ 2]);
|
||||
BODY_00_15( 3,D,E,T,A,B,C,W[ 3]);
|
||||
BODY_00_15( 4,C,D,E,T,A,B,W[ 4]);
|
||||
BODY_00_15( 5,B,C,D,E,T,A,W[ 5]);
|
||||
BODY_00_15( 6,A,B,C,D,E,T,W[ 6]);
|
||||
BODY_00_15( 7,T,A,B,C,D,E,W[ 7]);
|
||||
BODY_00_15( 8,E,T,A,B,C,D,W[ 8]);
|
||||
BODY_00_15( 9,D,E,T,A,B,C,W[ 9]);
|
||||
BODY_00_15(10,C,D,E,T,A,B,W[10]);
|
||||
BODY_00_15(11,B,C,D,E,T,A,W[11]);
|
||||
BODY_00_15(12,A,B,C,D,E,T,W[12]);
|
||||
BODY_00_15(13,T,A,B,C,D,E,W[13]);
|
||||
BODY_00_15(14,E,T,A,B,C,D,W[14]);
|
||||
BODY_00_15(15,D,E,T,A,B,C,W[15]);
|
||||
|
||||
BODY_16_19(16,C,D,E,T,A,B,X( 0),W[ 0],W[ 2],W[ 8],W[13]);
|
||||
BODY_16_19(17,B,C,D,E,T,A,X( 1),W[ 1],W[ 3],W[ 9],W[14]);
|
||||
BODY_16_19(18,A,B,C,D,E,T,X( 2),W[ 2],W[ 4],W[10],W[15]);
|
||||
BODY_16_19(19,T,A,B,C,D,E,X( 3),W[ 3],W[ 5],W[11],X( 0));
|
||||
|
||||
BODY_20_31(20,E,T,A,B,C,D,X( 4),W[ 4],W[ 6],W[12],X( 1));
|
||||
BODY_20_31(21,D,E,T,A,B,C,X( 5),W[ 5],W[ 7],W[13],X( 2));
|
||||
BODY_20_31(22,C,D,E,T,A,B,X( 6),W[ 6],W[ 8],W[14],X( 3));
|
||||
BODY_20_31(23,B,C,D,E,T,A,X( 7),W[ 7],W[ 9],W[15],X( 4));
|
||||
BODY_20_31(24,A,B,C,D,E,T,X( 8),W[ 8],W[10],X( 0),X( 5));
|
||||
BODY_20_31(25,T,A,B,C,D,E,X( 9),W[ 9],W[11],X( 1),X( 6));
|
||||
BODY_20_31(26,E,T,A,B,C,D,X(10),W[10],W[12],X( 2),X( 7));
|
||||
BODY_20_31(27,D,E,T,A,B,C,X(11),W[11],W[13],X( 3),X( 8));
|
||||
BODY_20_31(28,C,D,E,T,A,B,X(12),W[12],W[14],X( 4),X( 9));
|
||||
BODY_20_31(29,B,C,D,E,T,A,X(13),W[13],W[15],X( 5),X(10));
|
||||
BODY_20_31(30,A,B,C,D,E,T,X(14),W[14],X( 0),X( 6),X(11));
|
||||
BODY_20_31(31,T,A,B,C,D,E,X(15),W[15],X( 1),X( 7),X(12));
|
||||
|
||||
BODY_32_39(32,E,T,A,B,C,D,X( 0),X( 2),X( 8),X(13));
|
||||
BODY_32_39(33,D,E,T,A,B,C,X( 1),X( 3),X( 9),X(14));
|
||||
BODY_32_39(34,C,D,E,T,A,B,X( 2),X( 4),X(10),X(15));
|
||||
BODY_32_39(35,B,C,D,E,T,A,X( 3),X( 5),X(11),X( 0));
|
||||
BODY_32_39(36,A,B,C,D,E,T,X( 4),X( 6),X(12),X( 1));
|
||||
BODY_32_39(37,T,A,B,C,D,E,X( 5),X( 7),X(13),X( 2));
|
||||
BODY_32_39(38,E,T,A,B,C,D,X( 6),X( 8),X(14),X( 3));
|
||||
BODY_32_39(39,D,E,T,A,B,C,X( 7),X( 9),X(15),X( 4));
|
||||
|
||||
BODY_40_59(40,C,D,E,T,A,B,X( 8),X(10),X( 0),X( 5));
|
||||
BODY_40_59(41,B,C,D,E,T,A,X( 9),X(11),X( 1),X( 6));
|
||||
BODY_40_59(42,A,B,C,D,E,T,X(10),X(12),X( 2),X( 7));
|
||||
BODY_40_59(43,T,A,B,C,D,E,X(11),X(13),X( 3),X( 8));
|
||||
BODY_40_59(44,E,T,A,B,C,D,X(12),X(14),X( 4),X( 9));
|
||||
BODY_40_59(45,D,E,T,A,B,C,X(13),X(15),X( 5),X(10));
|
||||
BODY_40_59(46,C,D,E,T,A,B,X(14),X( 0),X( 6),X(11));
|
||||
BODY_40_59(47,B,C,D,E,T,A,X(15),X( 1),X( 7),X(12));
|
||||
BODY_40_59(48,A,B,C,D,E,T,X( 0),X( 2),X( 8),X(13));
|
||||
BODY_40_59(49,T,A,B,C,D,E,X( 1),X( 3),X( 9),X(14));
|
||||
BODY_40_59(50,E,T,A,B,C,D,X( 2),X( 4),X(10),X(15));
|
||||
BODY_40_59(51,D,E,T,A,B,C,X( 3),X( 5),X(11),X( 0));
|
||||
BODY_40_59(52,C,D,E,T,A,B,X( 4),X( 6),X(12),X( 1));
|
||||
BODY_40_59(53,B,C,D,E,T,A,X( 5),X( 7),X(13),X( 2));
|
||||
BODY_40_59(54,A,B,C,D,E,T,X( 6),X( 8),X(14),X( 3));
|
||||
BODY_40_59(55,T,A,B,C,D,E,X( 7),X( 9),X(15),X( 4));
|
||||
BODY_40_59(56,E,T,A,B,C,D,X( 8),X(10),X( 0),X( 5));
|
||||
BODY_40_59(57,D,E,T,A,B,C,X( 9),X(11),X( 1),X( 6));
|
||||
BODY_40_59(58,C,D,E,T,A,B,X(10),X(12),X( 2),X( 7));
|
||||
BODY_40_59(59,B,C,D,E,T,A,X(11),X(13),X( 3),X( 8));
|
||||
|
||||
BODY_60_79(60,A,B,C,D,E,T,X(12),X(14),X( 4),X( 9));
|
||||
BODY_60_79(61,T,A,B,C,D,E,X(13),X(15),X( 5),X(10));
|
||||
BODY_60_79(62,E,T,A,B,C,D,X(14),X( 0),X( 6),X(11));
|
||||
BODY_60_79(63,D,E,T,A,B,C,X(15),X( 1),X( 7),X(12));
|
||||
BODY_60_79(64,C,D,E,T,A,B,X( 0),X( 2),X( 8),X(13));
|
||||
BODY_60_79(65,B,C,D,E,T,A,X( 1),X( 3),X( 9),X(14));
|
||||
BODY_60_79(66,A,B,C,D,E,T,X( 2),X( 4),X(10),X(15));
|
||||
BODY_60_79(67,T,A,B,C,D,E,X( 3),X( 5),X(11),X( 0));
|
||||
BODY_60_79(68,E,T,A,B,C,D,X( 4),X( 6),X(12),X( 1));
|
||||
BODY_60_79(69,D,E,T,A,B,C,X( 5),X( 7),X(13),X( 2));
|
||||
BODY_60_79(70,C,D,E,T,A,B,X( 6),X( 8),X(14),X( 3));
|
||||
BODY_60_79(71,B,C,D,E,T,A,X( 7),X( 9),X(15),X( 4));
|
||||
BODY_60_79(72,A,B,C,D,E,T,X( 8),X(10),X( 0),X( 5));
|
||||
BODY_60_79(73,T,A,B,C,D,E,X( 9),X(11),X( 1),X( 6));
|
||||
BODY_60_79(74,E,T,A,B,C,D,X(10),X(12),X( 2),X( 7));
|
||||
BODY_60_79(75,D,E,T,A,B,C,X(11),X(13),X( 3),X( 8));
|
||||
BODY_60_79(76,C,D,E,T,A,B,X(12),X(14),X( 4),X( 9));
|
||||
BODY_60_79(77,B,C,D,E,T,A,X(13),X(15),X( 5),X(10));
|
||||
BODY_60_79(78,A,B,C,D,E,T,X(14),X( 0),X( 6),X(11));
|
||||
BODY_60_79(79,T,A,B,C,D,E,X(15),X( 1),X( 7),X(12));
|
||||
|
||||
c->h0=(c->h0+E)&0xffffffffL;
|
||||
c->h1=(c->h1+T)&0xffffffffL;
|
||||
c->h2=(c->h2+A)&0xffffffffL;
|
||||
c->h3=(c->h3+B)&0xffffffffL;
|
||||
c->h4=(c->h4+C)&0xffffffffL;
|
||||
|
||||
if (--num == 0) break;
|
||||
|
||||
A=c->h0;
|
||||
B=c->h1;
|
||||
C=c->h2;
|
||||
D=c->h3;
|
||||
E=c->h4;
|
||||
|
||||
W+=SHA_LBLOCK;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DONT_IMPLEMENT_BLOCK_DATA_ORDER
|
||||
void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, size_t num)
|
||||
{
|
||||
const unsigned char *data=p;
|
||||
register unsigned MD32_REG_T A,B,C,D,E,T,l;
|
||||
#ifndef MD32_XARRAY
|
||||
unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
|
||||
XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
|
||||
#else
|
||||
SHA_LONG XX[16];
|
||||
#endif
|
||||
|
||||
A=c->h0;
|
||||
B=c->h1;
|
||||
C=c->h2;
|
||||
D=c->h3;
|
||||
E=c->h4;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
||||
HOST_c2l(data,l); X( 0)=l; HOST_c2l(data,l); X( 1)=l;
|
||||
BODY_00_15( 0,A,B,C,D,E,T,X( 0)); HOST_c2l(data,l); X( 2)=l;
|
||||
BODY_00_15( 1,T,A,B,C,D,E,X( 1)); HOST_c2l(data,l); X( 3)=l;
|
||||
BODY_00_15( 2,E,T,A,B,C,D,X( 2)); HOST_c2l(data,l); X( 4)=l;
|
||||
BODY_00_15( 3,D,E,T,A,B,C,X( 3)); HOST_c2l(data,l); X( 5)=l;
|
||||
BODY_00_15( 4,C,D,E,T,A,B,X( 4)); HOST_c2l(data,l); X( 6)=l;
|
||||
BODY_00_15( 5,B,C,D,E,T,A,X( 5)); HOST_c2l(data,l); X( 7)=l;
|
||||
BODY_00_15( 6,A,B,C,D,E,T,X( 6)); HOST_c2l(data,l); X( 8)=l;
|
||||
BODY_00_15( 7,T,A,B,C,D,E,X( 7)); HOST_c2l(data,l); X( 9)=l;
|
||||
BODY_00_15( 8,E,T,A,B,C,D,X( 8)); HOST_c2l(data,l); X(10)=l;
|
||||
BODY_00_15( 9,D,E,T,A,B,C,X( 9)); HOST_c2l(data,l); X(11)=l;
|
||||
BODY_00_15(10,C,D,E,T,A,B,X(10)); HOST_c2l(data,l); X(12)=l;
|
||||
BODY_00_15(11,B,C,D,E,T,A,X(11)); HOST_c2l(data,l); X(13)=l;
|
||||
BODY_00_15(12,A,B,C,D,E,T,X(12)); HOST_c2l(data,l); X(14)=l;
|
||||
BODY_00_15(13,T,A,B,C,D,E,X(13)); HOST_c2l(data,l); X(15)=l;
|
||||
BODY_00_15(14,E,T,A,B,C,D,X(14));
|
||||
BODY_00_15(15,D,E,T,A,B,C,X(15));
|
||||
|
||||
BODY_16_19(16,C,D,E,T,A,B,X( 0),X( 0),X( 2),X( 8),X(13));
|
||||
BODY_16_19(17,B,C,D,E,T,A,X( 1),X( 1),X( 3),X( 9),X(14));
|
||||
BODY_16_19(18,A,B,C,D,E,T,X( 2),X( 2),X( 4),X(10),X(15));
|
||||
BODY_16_19(19,T,A,B,C,D,E,X( 3),X( 3),X( 5),X(11),X( 0));
|
||||
|
||||
BODY_20_31(20,E,T,A,B,C,D,X( 4),X( 4),X( 6),X(12),X( 1));
|
||||
BODY_20_31(21,D,E,T,A,B,C,X( 5),X( 5),X( 7),X(13),X( 2));
|
||||
BODY_20_31(22,C,D,E,T,A,B,X( 6),X( 6),X( 8),X(14),X( 3));
|
||||
BODY_20_31(23,B,C,D,E,T,A,X( 7),X( 7),X( 9),X(15),X( 4));
|
||||
BODY_20_31(24,A,B,C,D,E,T,X( 8),X( 8),X(10),X( 0),X( 5));
|
||||
BODY_20_31(25,T,A,B,C,D,E,X( 9),X( 9),X(11),X( 1),X( 6));
|
||||
BODY_20_31(26,E,T,A,B,C,D,X(10),X(10),X(12),X( 2),X( 7));
|
||||
BODY_20_31(27,D,E,T,A,B,C,X(11),X(11),X(13),X( 3),X( 8));
|
||||
BODY_20_31(28,C,D,E,T,A,B,X(12),X(12),X(14),X( 4),X( 9));
|
||||
BODY_20_31(29,B,C,D,E,T,A,X(13),X(13),X(15),X( 5),X(10));
|
||||
BODY_20_31(30,A,B,C,D,E,T,X(14),X(14),X( 0),X( 6),X(11));
|
||||
BODY_20_31(31,T,A,B,C,D,E,X(15),X(15),X( 1),X( 7),X(12));
|
||||
|
||||
BODY_32_39(32,E,T,A,B,C,D,X( 0),X( 2),X( 8),X(13));
|
||||
BODY_32_39(33,D,E,T,A,B,C,X( 1),X( 3),X( 9),X(14));
|
||||
BODY_32_39(34,C,D,E,T,A,B,X( 2),X( 4),X(10),X(15));
|
||||
BODY_32_39(35,B,C,D,E,T,A,X( 3),X( 5),X(11),X( 0));
|
||||
BODY_32_39(36,A,B,C,D,E,T,X( 4),X( 6),X(12),X( 1));
|
||||
BODY_32_39(37,T,A,B,C,D,E,X( 5),X( 7),X(13),X( 2));
|
||||
BODY_32_39(38,E,T,A,B,C,D,X( 6),X( 8),X(14),X( 3));
|
||||
BODY_32_39(39,D,E,T,A,B,C,X( 7),X( 9),X(15),X( 4));
|
||||
|
||||
BODY_40_59(40,C,D,E,T,A,B,X( 8),X(10),X( 0),X( 5));
|
||||
BODY_40_59(41,B,C,D,E,T,A,X( 9),X(11),X( 1),X( 6));
|
||||
BODY_40_59(42,A,B,C,D,E,T,X(10),X(12),X( 2),X( 7));
|
||||
BODY_40_59(43,T,A,B,C,D,E,X(11),X(13),X( 3),X( 8));
|
||||
BODY_40_59(44,E,T,A,B,C,D,X(12),X(14),X( 4),X( 9));
|
||||
BODY_40_59(45,D,E,T,A,B,C,X(13),X(15),X( 5),X(10));
|
||||
BODY_40_59(46,C,D,E,T,A,B,X(14),X( 0),X( 6),X(11));
|
||||
BODY_40_59(47,B,C,D,E,T,A,X(15),X( 1),X( 7),X(12));
|
||||
BODY_40_59(48,A,B,C,D,E,T,X( 0),X( 2),X( 8),X(13));
|
||||
BODY_40_59(49,T,A,B,C,D,E,X( 1),X( 3),X( 9),X(14));
|
||||
BODY_40_59(50,E,T,A,B,C,D,X( 2),X( 4),X(10),X(15));
|
||||
BODY_40_59(51,D,E,T,A,B,C,X( 3),X( 5),X(11),X( 0));
|
||||
BODY_40_59(52,C,D,E,T,A,B,X( 4),X( 6),X(12),X( 1));
|
||||
BODY_40_59(53,B,C,D,E,T,A,X( 5),X( 7),X(13),X( 2));
|
||||
BODY_40_59(54,A,B,C,D,E,T,X( 6),X( 8),X(14),X( 3));
|
||||
BODY_40_59(55,T,A,B,C,D,E,X( 7),X( 9),X(15),X( 4));
|
||||
BODY_40_59(56,E,T,A,B,C,D,X( 8),X(10),X( 0),X( 5));
|
||||
BODY_40_59(57,D,E,T,A,B,C,X( 9),X(11),X( 1),X( 6));
|
||||
BODY_40_59(58,C,D,E,T,A,B,X(10),X(12),X( 2),X( 7));
|
||||
BODY_40_59(59,B,C,D,E,T,A,X(11),X(13),X( 3),X( 8));
|
||||
|
||||
BODY_60_79(60,A,B,C,D,E,T,X(12),X(14),X( 4),X( 9));
|
||||
BODY_60_79(61,T,A,B,C,D,E,X(13),X(15),X( 5),X(10));
|
||||
BODY_60_79(62,E,T,A,B,C,D,X(14),X( 0),X( 6),X(11));
|
||||
BODY_60_79(63,D,E,T,A,B,C,X(15),X( 1),X( 7),X(12));
|
||||
BODY_60_79(64,C,D,E,T,A,B,X( 0),X( 2),X( 8),X(13));
|
||||
BODY_60_79(65,B,C,D,E,T,A,X( 1),X( 3),X( 9),X(14));
|
||||
BODY_60_79(66,A,B,C,D,E,T,X( 2),X( 4),X(10),X(15));
|
||||
BODY_60_79(67,T,A,B,C,D,E,X( 3),X( 5),X(11),X( 0));
|
||||
BODY_60_79(68,E,T,A,B,C,D,X( 4),X( 6),X(12),X( 1));
|
||||
BODY_60_79(69,D,E,T,A,B,C,X( 5),X( 7),X(13),X( 2));
|
||||
BODY_60_79(70,C,D,E,T,A,B,X( 6),X( 8),X(14),X( 3));
|
||||
BODY_60_79(71,B,C,D,E,T,A,X( 7),X( 9),X(15),X( 4));
|
||||
BODY_60_79(72,A,B,C,D,E,T,X( 8),X(10),X( 0),X( 5));
|
||||
BODY_60_79(73,T,A,B,C,D,E,X( 9),X(11),X( 1),X( 6));
|
||||
BODY_60_79(74,E,T,A,B,C,D,X(10),X(12),X( 2),X( 7));
|
||||
BODY_60_79(75,D,E,T,A,B,C,X(11),X(13),X( 3),X( 8));
|
||||
BODY_60_79(76,C,D,E,T,A,B,X(12),X(14),X( 4),X( 9));
|
||||
BODY_60_79(77,B,C,D,E,T,A,X(13),X(15),X( 5),X(10));
|
||||
BODY_60_79(78,A,B,C,D,E,T,X(14),X( 0),X( 6),X(11));
|
||||
BODY_60_79(79,T,A,B,C,D,E,X(15),X( 1),X( 7),X(12));
|
||||
|
||||
c->h0=(c->h0+E)&0xffffffffL;
|
||||
c->h1=(c->h1+T)&0xffffffffL;
|
||||
c->h2=(c->h2+A)&0xffffffffL;
|
||||
c->h3=(c->h3+B)&0xffffffffL;
|
||||
c->h4=(c->h4+C)&0xffffffffL;
|
||||
|
||||
if (--num == 0) break;
|
||||
|
||||
A=c->h0;
|
||||
B=c->h1;
|
||||
C=c->h2;
|
||||
D=c->h3;
|
||||
E=c->h4;
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#else /* OPENSSL_SMALL_FOOTPRINT */
|
||||
|
||||
#define BODY_00_15(xi) do { \
|
||||
T=E+K_00_19+F_00_19(B,C,D); \
|
||||
E=D, D=C, C=ROTATE(B,30), B=A; \
|
||||
A=ROTATE(A,5)+T+xi; } while(0)
|
||||
|
||||
#define BODY_16_19(xa,xb,xc,xd) do { \
|
||||
Xupdate(T,xa,xa,xb,xc,xd); \
|
||||
T+=E+K_00_19+F_00_19(B,C,D); \
|
||||
E=D, D=C, C=ROTATE(B,30), B=A; \
|
||||
A=ROTATE(A,5)+T; } while(0)
|
||||
|
||||
#define BODY_20_39(xa,xb,xc,xd) do { \
|
||||
Xupdate(T,xa,xa,xb,xc,xd); \
|
||||
T+=E+K_20_39+F_20_39(B,C,D); \
|
||||
E=D, D=C, C=ROTATE(B,30), B=A; \
|
||||
A=ROTATE(A,5)+T; } while(0)
|
||||
|
||||
#define BODY_40_59(xa,xb,xc,xd) do { \
|
||||
Xupdate(T,xa,xa,xb,xc,xd); \
|
||||
T+=E+K_40_59+F_40_59(B,C,D); \
|
||||
E=D, D=C, C=ROTATE(B,30), B=A; \
|
||||
A=ROTATE(A,5)+T; } while(0)
|
||||
|
||||
#define BODY_60_79(xa,xb,xc,xd) do { \
|
||||
Xupdate(T,xa,xa,xb,xc,xd); \
|
||||
T=E+K_60_79+F_60_79(B,C,D); \
|
||||
E=D, D=C, C=ROTATE(B,30), B=A; \
|
||||
A=ROTATE(A,5)+T+xa; } while(0)
|
||||
|
||||
#ifndef DONT_IMPLEMENT_BLOCK_HOST_ORDER
|
||||
void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, size_t num)
|
||||
{
|
||||
const SHA_LONG *W=d;
|
||||
register unsigned MD32_REG_T A,B,C,D,E,T;
|
||||
int i;
|
||||
SHA_LONG X[16];
|
||||
|
||||
A=c->h0;
|
||||
B=c->h1;
|
||||
C=c->h2;
|
||||
D=c->h3;
|
||||
E=c->h4;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
for (i=0;i<16;i++)
|
||||
{ X[i]=W[i]; BODY_00_15(X[i]); }
|
||||
for (i=0;i<4;i++)
|
||||
{ BODY_16_19(X[i], X[i+2], X[i+8], X[(i+13)&15]); }
|
||||
for (;i<24;i++)
|
||||
{ BODY_20_39(X[i&15], X[(i+2)&15], X[(i+8)&15],X[(i+13)&15]); }
|
||||
for (i=0;i<20;i++)
|
||||
{ BODY_40_59(X[(i+8)&15],X[(i+10)&15],X[i&15], X[(i+5)&15]); }
|
||||
for (i=4;i<24;i++)
|
||||
{ BODY_60_79(X[(i+8)&15],X[(i+10)&15],X[i&15], X[(i+5)&15]); }
|
||||
|
||||
c->h0=(c->h0+A)&0xffffffffL;
|
||||
c->h1=(c->h1+B)&0xffffffffL;
|
||||
c->h2=(c->h2+C)&0xffffffffL;
|
||||
c->h3=(c->h3+D)&0xffffffffL;
|
||||
c->h4=(c->h4+E)&0xffffffffL;
|
||||
|
||||
if (--num == 0) break;
|
||||
|
||||
A=c->h0;
|
||||
B=c->h1;
|
||||
C=c->h2;
|
||||
D=c->h3;
|
||||
E=c->h4;
|
||||
|
||||
W+=SHA_LBLOCK;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DONT_IMPLEMENT_BLOCK_DATA_ORDER
|
||||
void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, size_t num)
|
||||
{
|
||||
const unsigned char *data=p;
|
||||
register unsigned MD32_REG_T A,B,C,D,E,T,l;
|
||||
int i;
|
||||
SHA_LONG X[16];
|
||||
|
||||
A=c->h0;
|
||||
B=c->h1;
|
||||
C=c->h2;
|
||||
D=c->h3;
|
||||
E=c->h4;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
for (i=0;i<16;i++)
|
||||
{ HOST_c2l(data,l); X[i]=l; BODY_00_15(X[i]); }
|
||||
for (i=0;i<4;i++)
|
||||
{ BODY_16_19(X[i], X[i+2], X[i+8], X[(i+13)&15]); }
|
||||
for (;i<24;i++)
|
||||
{ BODY_20_39(X[i&15], X[(i+2)&15], X[(i+8)&15],X[(i+13)&15]); }
|
||||
for (i=0;i<20;i++)
|
||||
{ BODY_40_59(X[(i+8)&15],X[(i+10)&15],X[i&15], X[(i+5)&15]); }
|
||||
for (i=4;i<24;i++)
|
||||
{ BODY_60_79(X[(i+8)&15],X[(i+10)&15],X[i&15], X[(i+5)&15]); }
|
||||
|
||||
c->h0=(c->h0+A)&0xffffffffL;
|
||||
c->h1=(c->h1+B)&0xffffffffL;
|
||||
c->h2=(c->h2+C)&0xffffffffL;
|
||||
c->h3=(c->h3+D)&0xffffffffL;
|
||||
c->h4=(c->h4+E)&0xffffffffL;
|
||||
|
||||
if (--num == 0) break;
|
||||
|
||||
A=c->h0;
|
||||
B=c->h1;
|
||||
C=c->h2;
|
||||
D=c->h3;
|
||||
E=c->h4;
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
109
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/stack.h
Executable file
109
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/include/openssl/stack.h
Executable file
@ -0,0 +1,109 @@
|
||||
/* crypto/stack/stack.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_STACK_H
|
||||
#define HEADER_STACK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct stack_st
|
||||
{
|
||||
int num;
|
||||
char **data;
|
||||
int sorted;
|
||||
|
||||
int num_alloc;
|
||||
int (*comp)(const char * const *, const char * const *);
|
||||
} STACK;
|
||||
|
||||
#define M_sk_num(sk) ((sk) ? (sk)->num:-1)
|
||||
#define M_sk_value(sk,n) ((sk) ? (sk)->data[n] : NULL)
|
||||
|
||||
int sk_num(const STACK *);
|
||||
char *sk_value(const STACK *, int);
|
||||
|
||||
char *sk_set(STACK *, int, char *);
|
||||
|
||||
STACK *sk_new(int (*cmp)(const char * const *, const char * const *));
|
||||
STACK *sk_new_null(void);
|
||||
void sk_free(STACK *);
|
||||
void sk_pop_free(STACK *st, void (*func)(void *));
|
||||
int sk_insert(STACK *sk,char *data,int where);
|
||||
char *sk_delete(STACK *st,int loc);
|
||||
char *sk_delete_ptr(STACK *st, char *p);
|
||||
int sk_find(STACK *st,char *data);
|
||||
int sk_find_ex(STACK *st,char *data);
|
||||
int sk_push(STACK *st,char *data);
|
||||
int sk_unshift(STACK *st,char *data);
|
||||
char *sk_shift(STACK *st);
|
||||
char *sk_pop(STACK *st);
|
||||
void sk_zero(STACK *st);
|
||||
int (*sk_set_cmp_func(STACK *sk, int (*c)(const char * const *,
|
||||
const char * const *)))
|
||||
(const char * const *, const char * const *);
|
||||
STACK *sk_dup(STACK *st);
|
||||
void sk_sort(STACK *st);
|
||||
int sk_is_sorted(const STACK *st);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
121
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/md5/Makefile.old
Executable file
121
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/md5/Makefile.old
Executable file
@ -0,0 +1,121 @@
|
||||
#
|
||||
# OpenSSL/crypto/md5/Makefile
|
||||
#
|
||||
|
||||
DIR= md5
|
||||
TOP= ../..
|
||||
CC= cc
|
||||
CPP= $(CC) -E
|
||||
INCLUDES=-I.. -I$(TOP) -I../../include
|
||||
CFLAG=-g
|
||||
MAKEFILE= Makefile
|
||||
AR= ar r
|
||||
|
||||
MD5_ASM_OBJ=
|
||||
|
||||
CFLAGS= $(INCLUDES) $(CFLAG)
|
||||
ASFLAGS= $(INCLUDES) $(ASFLAG)
|
||||
AFLAGS= $(ASFLAGS)
|
||||
|
||||
GENERAL=Makefile
|
||||
TEST=md5test.c
|
||||
APPS=
|
||||
|
||||
LIB=$(TOP)/libcrypto.a
|
||||
LIBSRC=md5_dgst.c md5_one.c
|
||||
LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ)
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
EXHEADER= md5.h
|
||||
HEADER= md5_locl.h $(EXHEADER)
|
||||
|
||||
ALL= $(GENERAL) $(SRC) $(HEADER)
|
||||
|
||||
top:
|
||||
(cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
|
||||
|
||||
all: lib
|
||||
|
||||
lib: $(LIBOBJ)
|
||||
$(AR) $(LIB) $(LIBOBJ)
|
||||
$(RANLIB) $(LIB) || echo Never mind.
|
||||
@touch lib
|
||||
|
||||
# ELF
|
||||
mx86-elf.s: asm/md5-586.pl ../perlasm/x86asm.pl
|
||||
(cd asm; $(PERL) md5-586.pl elf $(CFLAGS) > ../$@)
|
||||
# COFF
|
||||
mx86-cof.s: asm/md5-586.pl ../perlasm/x86asm.pl
|
||||
(cd asm; $(PERL) md5-586.pl coff $(CFLAGS) > ../$@)
|
||||
# a.out
|
||||
mx86-out.s: asm/md5-586.pl ../perlasm/x86asm.pl
|
||||
(cd asm; $(PERL) md5-586.pl a.out $(CFLAGS) > ../$@)
|
||||
|
||||
md5-sparcv8plus.o: asm/md5-sparcv9.S
|
||||
$(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -c \
|
||||
-o md5-sparcv8plus.o asm/md5-sparcv9.S
|
||||
|
||||
# Old GNU assembler doesn't understand V9 instructions, so we
|
||||
# hire /usr/ccs/bin/as to do the job. Note that option is called
|
||||
# *-gcc27, but even gcc 2>=8 users may experience similar problem
|
||||
# if they didn't bother to upgrade GNU assembler. Such users should
|
||||
# not choose this option, but be adviced to *remove* GNU assembler
|
||||
# or upgrade it.
|
||||
md5-sparcv8plus-gcc27.o: asm/md5-sparcv9.S
|
||||
$(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -E asm/md5-sparcv9.S | \
|
||||
/usr/ccs/bin/as -xarch=v8plus - -o md5-sparcv8plus-gcc27.o
|
||||
|
||||
md5-sparcv9.o: asm/md5-sparcv9.S
|
||||
$(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -c \
|
||||
-o md5-sparcv9.o asm/md5-sparcv9.S
|
||||
|
||||
md5-x86_64.s: asm/md5-x86_64.pl; $(PERL) asm/md5-x86_64.pl $@
|
||||
|
||||
files:
|
||||
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
|
||||
|
||||
links:
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
|
||||
|
||||
install:
|
||||
@[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
|
||||
@headerlist="$(EXHEADER)"; for i in $$headerlist ; \
|
||||
do \
|
||||
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
|
||||
done;
|
||||
|
||||
tags:
|
||||
ctags $(SRC)
|
||||
|
||||
tests:
|
||||
|
||||
lint:
|
||||
lint -DLINT $(INCLUDES) $(SRC)>fluff
|
||||
|
||||
depend:
|
||||
@[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
|
||||
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
|
||||
|
||||
dclean:
|
||||
$(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
|
||||
mv -f Makefile.new $(MAKEFILE)
|
||||
|
||||
clean:
|
||||
rm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
md5_dgst.o: ../../../include/rtk_arch.h ../../include/openssl/e_os2.h
|
||||
md5_dgst.o: ../../include/openssl/md5.h ../../include/openssl/opensslconf.h
|
||||
md5_dgst.o: ../../include/openssl/opensslv.h ../md32_common.h md5_dgst.c
|
||||
md5_dgst.o: md5_locl.h
|
||||
md5_one.o: ../../../include/rtk_arch.h ../../include/openssl/crypto.h
|
||||
md5_one.o: ../../include/openssl/e_os2.h ../../include/openssl/md5.h
|
||||
md5_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
md5_one.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
|
||||
md5_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
md5_one.o: md5_one.c
|
121
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/md5/Makefile.save
Executable file
121
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/md5/Makefile.save
Executable file
@ -0,0 +1,121 @@
|
||||
#
|
||||
# OpenSSL/crypto/md5/Makefile
|
||||
#
|
||||
|
||||
DIR= md5
|
||||
TOP= ../..
|
||||
CC= cc
|
||||
CPP= $(CC) -E
|
||||
INCLUDES=-I.. -I$(TOP) -I../../include
|
||||
CFLAG=-g
|
||||
MAKEFILE= Makefile
|
||||
AR= ar r
|
||||
|
||||
MD5_ASM_OBJ=
|
||||
|
||||
CFLAGS= $(INCLUDES) $(CFLAG)
|
||||
ASFLAGS= $(INCLUDES) $(ASFLAG)
|
||||
AFLAGS= $(ASFLAGS)
|
||||
|
||||
GENERAL=Makefile
|
||||
TEST=md5test.c
|
||||
APPS=
|
||||
|
||||
LIB=$(TOP)/libcrypto.a
|
||||
LIBSRC=md5_dgst.c md5_one.c
|
||||
LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ)
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
EXHEADER= md5.h
|
||||
HEADER= md5_locl.h $(EXHEADER)
|
||||
|
||||
ALL= $(GENERAL) $(SRC) $(HEADER)
|
||||
|
||||
top:
|
||||
(cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
|
||||
|
||||
all: lib
|
||||
|
||||
lib: $(LIBOBJ)
|
||||
$(AR) $(LIB) $(LIBOBJ)
|
||||
$(RANLIB) $(LIB) || echo Never mind.
|
||||
@touch lib
|
||||
|
||||
# ELF
|
||||
mx86-elf.s: asm/md5-586.pl ../perlasm/x86asm.pl
|
||||
(cd asm; $(PERL) md5-586.pl elf $(CFLAGS) > ../$@)
|
||||
# COFF
|
||||
mx86-cof.s: asm/md5-586.pl ../perlasm/x86asm.pl
|
||||
(cd asm; $(PERL) md5-586.pl coff $(CFLAGS) > ../$@)
|
||||
# a.out
|
||||
mx86-out.s: asm/md5-586.pl ../perlasm/x86asm.pl
|
||||
(cd asm; $(PERL) md5-586.pl a.out $(CFLAGS) > ../$@)
|
||||
|
||||
md5-sparcv8plus.o: asm/md5-sparcv9.S
|
||||
$(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -c \
|
||||
-o md5-sparcv8plus.o asm/md5-sparcv9.S
|
||||
|
||||
# Old GNU assembler doesn't understand V9 instructions, so we
|
||||
# hire /usr/ccs/bin/as to do the job. Note that option is called
|
||||
# *-gcc27, but even gcc 2>=8 users may experience similar problem
|
||||
# if they didn't bother to upgrade GNU assembler. Such users should
|
||||
# not choose this option, but be adviced to *remove* GNU assembler
|
||||
# or upgrade it.
|
||||
md5-sparcv8plus-gcc27.o: asm/md5-sparcv9.S
|
||||
$(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -E asm/md5-sparcv9.S | \
|
||||
/usr/ccs/bin/as -xarch=v8plus - -o md5-sparcv8plus-gcc27.o
|
||||
|
||||
md5-sparcv9.o: asm/md5-sparcv9.S
|
||||
$(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -c \
|
||||
-o md5-sparcv9.o asm/md5-sparcv9.S
|
||||
|
||||
md5-x86_64.s: asm/md5-x86_64.pl; $(PERL) asm/md5-x86_64.pl $@
|
||||
|
||||
files:
|
||||
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
|
||||
|
||||
links:
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
|
||||
|
||||
install:
|
||||
@[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
|
||||
@headerlist="$(EXHEADER)"; for i in $$headerlist ; \
|
||||
do \
|
||||
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
|
||||
done;
|
||||
|
||||
tags:
|
||||
ctags $(SRC)
|
||||
|
||||
tests:
|
||||
|
||||
lint:
|
||||
lint -DLINT $(INCLUDES) $(SRC)>fluff
|
||||
|
||||
depend:
|
||||
@[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
|
||||
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
|
||||
|
||||
dclean:
|
||||
$(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
|
||||
mv -f Makefile.new $(MAKEFILE)
|
||||
|
||||
clean:
|
||||
rm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
md5_dgst.o: ../../../include/rtk_arch.h ../../include/openssl/e_os2.h
|
||||
md5_dgst.o: ../../include/openssl/md5.h ../../include/openssl/opensslconf.h
|
||||
md5_dgst.o: ../../include/openssl/opensslv.h ../md32_common.h md5_dgst.c
|
||||
md5_dgst.o: md5_locl.h
|
||||
md5_one.o: ../../../include/rtk_arch.h ../../include/openssl/crypto.h
|
||||
md5_one.o: ../../include/openssl/e_os2.h ../../include/openssl/md5.h
|
||||
md5_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
md5_one.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
|
||||
md5_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
md5_one.o: md5_one.c
|
127
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/md5/md5.c
Executable file
127
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/md5/md5.c
Executable file
@ -0,0 +1,127 @@
|
||||
/* crypto/md5/md5.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <openssl/md5.h>
|
||||
|
||||
#define BUFSIZE 1024*16
|
||||
|
||||
void do_fp(FILE *f);
|
||||
void pt(unsigned char *md);
|
||||
#if !defined(_OSD_POSIX) && !defined(__DJGPP__)
|
||||
int read(int, void *, unsigned int);
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i,err=0;
|
||||
FILE *IN;
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
do_fp(stdin);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=1; i<argc; i++)
|
||||
{
|
||||
IN=fopen(argv[i],"r");
|
||||
if (IN == NULL)
|
||||
{
|
||||
perror(argv[i]);
|
||||
err++;
|
||||
continue;
|
||||
}
|
||||
printf("MD5(%s)= ",argv[i]);
|
||||
do_fp(IN);
|
||||
fclose(IN);
|
||||
}
|
||||
}
|
||||
exit(err);
|
||||
}
|
||||
|
||||
void do_fp(FILE *f)
|
||||
{
|
||||
MD5_CTX c;
|
||||
unsigned char md[MD5_DIGEST_LENGTH];
|
||||
int fd;
|
||||
int i;
|
||||
static unsigned char buf[BUFSIZE];
|
||||
|
||||
fd=fileno(f);
|
||||
MD5_Init(&c);
|
||||
for (;;)
|
||||
{
|
||||
i=read(fd,buf,BUFSIZE);
|
||||
if (i <= 0) break;
|
||||
MD5_Update(&c,buf,(unsigned long)i);
|
||||
}
|
||||
MD5_Final(&(md[0]),&c);
|
||||
pt(md);
|
||||
}
|
||||
|
||||
void pt(unsigned char *md)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<MD5_DIGEST_LENGTH; i++)
|
||||
printf("%02x",md[i]);
|
||||
printf("\n");
|
||||
}
|
||||
|
116
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/md5/md5.h
Executable file
116
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/md5/md5.h
Executable file
@ -0,0 +1,116 @@
|
||||
/* crypto/md5/md5.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_MD5_H
|
||||
#define HEADER_MD5_H
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef OPENSSL_NO_MD5
|
||||
#error MD5 is disabled.
|
||||
#endif
|
||||
|
||||
/*
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* ! MD5_LONG has to be at least 32 bits wide. If it's wider, then !
|
||||
* ! MD5_LONG_LOG2 has to be defined along. !
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*/
|
||||
|
||||
#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__)
|
||||
#define MD5_LONG unsigned long
|
||||
#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
|
||||
#define MD5_LONG unsigned long
|
||||
#define MD5_LONG_LOG2 3
|
||||
/*
|
||||
* _CRAY note. I could declare short, but I have no idea what impact
|
||||
* does it have on performance on none-T3E machines. I could declare
|
||||
* int, but at least on C90 sizeof(int) can be chosen at compile time.
|
||||
* So I've chosen long...
|
||||
* <appro@fy.chalmers.se>
|
||||
*/
|
||||
#else
|
||||
#define MD5_LONG unsigned int
|
||||
#endif
|
||||
|
||||
#define MD5_CBLOCK 64
|
||||
#define MD5_LBLOCK (MD5_CBLOCK/4)
|
||||
#define MD5_DIGEST_LENGTH 16
|
||||
|
||||
typedef struct MD5state_st
|
||||
{
|
||||
MD5_LONG A,B,C,D;
|
||||
MD5_LONG Nl,Nh;
|
||||
MD5_LONG data[MD5_LBLOCK];
|
||||
unsigned int num;
|
||||
} MD5_CTX;
|
||||
|
||||
int MD5_Init(MD5_CTX *c);
|
||||
int MD5_Update(MD5_CTX *c, const void *data, size_t len);
|
||||
int MD5_Final(unsigned char *md, MD5_CTX *c);
|
||||
unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md);
|
||||
void MD5_Transform(MD5_CTX *c, const unsigned char *b);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
292
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/md5/md5_dgst.c
Executable file
292
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/md5/md5_dgst.c
Executable file
@ -0,0 +1,292 @@
|
||||
/* crypto/md5/md5_dgst.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "md5_locl.h"
|
||||
#include <openssl/opensslv.h>
|
||||
|
||||
const char *MD5_version="MD5" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
/* Implemented from RFC1321 The MD5 Message-Digest Algorithm
|
||||
*/
|
||||
|
||||
#define INIT_DATA_A (unsigned long)0x67452301L
|
||||
#define INIT_DATA_B (unsigned long)0xefcdab89L
|
||||
#define INIT_DATA_C (unsigned long)0x98badcfeL
|
||||
#define INIT_DATA_D (unsigned long)0x10325476L
|
||||
|
||||
int MD5_Init(MD5_CTX *c)
|
||||
{
|
||||
c->A=INIT_DATA_A;
|
||||
c->B=INIT_DATA_B;
|
||||
c->C=INIT_DATA_C;
|
||||
c->D=INIT_DATA_D;
|
||||
c->Nl=0;
|
||||
c->Nh=0;
|
||||
c->num=0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef md5_block_host_order
|
||||
void md5_block_host_order (MD5_CTX *c, const void *data, size_t num)
|
||||
{
|
||||
const MD5_LONG *X=data;
|
||||
register unsigned MD32_REG_T A,B,C,D;
|
||||
|
||||
A=c->A;
|
||||
B=c->B;
|
||||
C=c->C;
|
||||
D=c->D;
|
||||
|
||||
for (;num--;X+=HASH_LBLOCK)
|
||||
{
|
||||
/* Round 0 */
|
||||
R0(A,B,C,D,X[ 0], 7,0xd76aa478L);
|
||||
R0(D,A,B,C,X[ 1],12,0xe8c7b756L);
|
||||
R0(C,D,A,B,X[ 2],17,0x242070dbL);
|
||||
R0(B,C,D,A,X[ 3],22,0xc1bdceeeL);
|
||||
R0(A,B,C,D,X[ 4], 7,0xf57c0fafL);
|
||||
R0(D,A,B,C,X[ 5],12,0x4787c62aL);
|
||||
R0(C,D,A,B,X[ 6],17,0xa8304613L);
|
||||
R0(B,C,D,A,X[ 7],22,0xfd469501L);
|
||||
R0(A,B,C,D,X[ 8], 7,0x698098d8L);
|
||||
R0(D,A,B,C,X[ 9],12,0x8b44f7afL);
|
||||
R0(C,D,A,B,X[10],17,0xffff5bb1L);
|
||||
R0(B,C,D,A,X[11],22,0x895cd7beL);
|
||||
R0(A,B,C,D,X[12], 7,0x6b901122L);
|
||||
R0(D,A,B,C,X[13],12,0xfd987193L);
|
||||
R0(C,D,A,B,X[14],17,0xa679438eL);
|
||||
R0(B,C,D,A,X[15],22,0x49b40821L);
|
||||
/* Round 1 */
|
||||
R1(A,B,C,D,X[ 1], 5,0xf61e2562L);
|
||||
R1(D,A,B,C,X[ 6], 9,0xc040b340L);
|
||||
R1(C,D,A,B,X[11],14,0x265e5a51L);
|
||||
R1(B,C,D,A,X[ 0],20,0xe9b6c7aaL);
|
||||
R1(A,B,C,D,X[ 5], 5,0xd62f105dL);
|
||||
R1(D,A,B,C,X[10], 9,0x02441453L);
|
||||
R1(C,D,A,B,X[15],14,0xd8a1e681L);
|
||||
R1(B,C,D,A,X[ 4],20,0xe7d3fbc8L);
|
||||
R1(A,B,C,D,X[ 9], 5,0x21e1cde6L);
|
||||
R1(D,A,B,C,X[14], 9,0xc33707d6L);
|
||||
R1(C,D,A,B,X[ 3],14,0xf4d50d87L);
|
||||
R1(B,C,D,A,X[ 8],20,0x455a14edL);
|
||||
R1(A,B,C,D,X[13], 5,0xa9e3e905L);
|
||||
R1(D,A,B,C,X[ 2], 9,0xfcefa3f8L);
|
||||
R1(C,D,A,B,X[ 7],14,0x676f02d9L);
|
||||
R1(B,C,D,A,X[12],20,0x8d2a4c8aL);
|
||||
/* Round 2 */
|
||||
R2(A,B,C,D,X[ 5], 4,0xfffa3942L);
|
||||
R2(D,A,B,C,X[ 8],11,0x8771f681L);
|
||||
R2(C,D,A,B,X[11],16,0x6d9d6122L);
|
||||
R2(B,C,D,A,X[14],23,0xfde5380cL);
|
||||
R2(A,B,C,D,X[ 1], 4,0xa4beea44L);
|
||||
R2(D,A,B,C,X[ 4],11,0x4bdecfa9L);
|
||||
R2(C,D,A,B,X[ 7],16,0xf6bb4b60L);
|
||||
R2(B,C,D,A,X[10],23,0xbebfbc70L);
|
||||
R2(A,B,C,D,X[13], 4,0x289b7ec6L);
|
||||
R2(D,A,B,C,X[ 0],11,0xeaa127faL);
|
||||
R2(C,D,A,B,X[ 3],16,0xd4ef3085L);
|
||||
R2(B,C,D,A,X[ 6],23,0x04881d05L);
|
||||
R2(A,B,C,D,X[ 9], 4,0xd9d4d039L);
|
||||
R2(D,A,B,C,X[12],11,0xe6db99e5L);
|
||||
R2(C,D,A,B,X[15],16,0x1fa27cf8L);
|
||||
R2(B,C,D,A,X[ 2],23,0xc4ac5665L);
|
||||
/* Round 3 */
|
||||
R3(A,B,C,D,X[ 0], 6,0xf4292244L);
|
||||
R3(D,A,B,C,X[ 7],10,0x432aff97L);
|
||||
R3(C,D,A,B,X[14],15,0xab9423a7L);
|
||||
R3(B,C,D,A,X[ 5],21,0xfc93a039L);
|
||||
R3(A,B,C,D,X[12], 6,0x655b59c3L);
|
||||
R3(D,A,B,C,X[ 3],10,0x8f0ccc92L);
|
||||
R3(C,D,A,B,X[10],15,0xffeff47dL);
|
||||
R3(B,C,D,A,X[ 1],21,0x85845dd1L);
|
||||
R3(A,B,C,D,X[ 8], 6,0x6fa87e4fL);
|
||||
R3(D,A,B,C,X[15],10,0xfe2ce6e0L);
|
||||
R3(C,D,A,B,X[ 6],15,0xa3014314L);
|
||||
R3(B,C,D,A,X[13],21,0x4e0811a1L);
|
||||
R3(A,B,C,D,X[ 4], 6,0xf7537e82L);
|
||||
R3(D,A,B,C,X[11],10,0xbd3af235L);
|
||||
R3(C,D,A,B,X[ 2],15,0x2ad7d2bbL);
|
||||
R3(B,C,D,A,X[ 9],21,0xeb86d391L);
|
||||
|
||||
A = c->A += A;
|
||||
B = c->B += B;
|
||||
C = c->C += C;
|
||||
D = c->D += D;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef md5_block_data_order
|
||||
#ifdef X
|
||||
#undef X
|
||||
#endif
|
||||
void md5_block_data_order (MD5_CTX *c, const void *data_, size_t num)
|
||||
{
|
||||
const unsigned char *data=data_;
|
||||
register unsigned MD32_REG_T A,B,C,D,l;
|
||||
#ifndef MD32_XARRAY
|
||||
/* See comment in crypto/sha/sha_locl.h for details. */
|
||||
unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
|
||||
XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
|
||||
# define X(i) XX##i
|
||||
#else
|
||||
MD5_LONG XX[MD5_LBLOCK];
|
||||
# define X(i) XX[i]
|
||||
#endif
|
||||
|
||||
A=c->A;
|
||||
B=c->B;
|
||||
C=c->C;
|
||||
D=c->D;
|
||||
|
||||
for (;num--;)
|
||||
{
|
||||
HOST_c2l(data,l); X( 0)=l; HOST_c2l(data,l); X( 1)=l;
|
||||
/* Round 0 */
|
||||
R0(A,B,C,D,X( 0), 7,0xd76aa478L); HOST_c2l(data,l); X( 2)=l;
|
||||
R0(D,A,B,C,X( 1),12,0xe8c7b756L); HOST_c2l(data,l); X( 3)=l;
|
||||
R0(C,D,A,B,X( 2),17,0x242070dbL); HOST_c2l(data,l); X( 4)=l;
|
||||
R0(B,C,D,A,X( 3),22,0xc1bdceeeL); HOST_c2l(data,l); X( 5)=l;
|
||||
R0(A,B,C,D,X( 4), 7,0xf57c0fafL); HOST_c2l(data,l); X( 6)=l;
|
||||
R0(D,A,B,C,X( 5),12,0x4787c62aL); HOST_c2l(data,l); X( 7)=l;
|
||||
R0(C,D,A,B,X( 6),17,0xa8304613L); HOST_c2l(data,l); X( 8)=l;
|
||||
R0(B,C,D,A,X( 7),22,0xfd469501L); HOST_c2l(data,l); X( 9)=l;
|
||||
R0(A,B,C,D,X( 8), 7,0x698098d8L); HOST_c2l(data,l); X(10)=l;
|
||||
R0(D,A,B,C,X( 9),12,0x8b44f7afL); HOST_c2l(data,l); X(11)=l;
|
||||
R0(C,D,A,B,X(10),17,0xffff5bb1L); HOST_c2l(data,l); X(12)=l;
|
||||
R0(B,C,D,A,X(11),22,0x895cd7beL); HOST_c2l(data,l); X(13)=l;
|
||||
R0(A,B,C,D,X(12), 7,0x6b901122L); HOST_c2l(data,l); X(14)=l;
|
||||
R0(D,A,B,C,X(13),12,0xfd987193L); HOST_c2l(data,l); X(15)=l;
|
||||
R0(C,D,A,B,X(14),17,0xa679438eL);
|
||||
R0(B,C,D,A,X(15),22,0x49b40821L);
|
||||
/* Round 1 */
|
||||
R1(A,B,C,D,X( 1), 5,0xf61e2562L);
|
||||
R1(D,A,B,C,X( 6), 9,0xc040b340L);
|
||||
R1(C,D,A,B,X(11),14,0x265e5a51L);
|
||||
R1(B,C,D,A,X( 0),20,0xe9b6c7aaL);
|
||||
R1(A,B,C,D,X( 5), 5,0xd62f105dL);
|
||||
R1(D,A,B,C,X(10), 9,0x02441453L);
|
||||
R1(C,D,A,B,X(15),14,0xd8a1e681L);
|
||||
R1(B,C,D,A,X( 4),20,0xe7d3fbc8L);
|
||||
R1(A,B,C,D,X( 9), 5,0x21e1cde6L);
|
||||
R1(D,A,B,C,X(14), 9,0xc33707d6L);
|
||||
R1(C,D,A,B,X( 3),14,0xf4d50d87L);
|
||||
R1(B,C,D,A,X( 8),20,0x455a14edL);
|
||||
R1(A,B,C,D,X(13), 5,0xa9e3e905L);
|
||||
R1(D,A,B,C,X( 2), 9,0xfcefa3f8L);
|
||||
R1(C,D,A,B,X( 7),14,0x676f02d9L);
|
||||
R1(B,C,D,A,X(12),20,0x8d2a4c8aL);
|
||||
/* Round 2 */
|
||||
R2(A,B,C,D,X( 5), 4,0xfffa3942L);
|
||||
R2(D,A,B,C,X( 8),11,0x8771f681L);
|
||||
R2(C,D,A,B,X(11),16,0x6d9d6122L);
|
||||
R2(B,C,D,A,X(14),23,0xfde5380cL);
|
||||
R2(A,B,C,D,X( 1), 4,0xa4beea44L);
|
||||
R2(D,A,B,C,X( 4),11,0x4bdecfa9L);
|
||||
R2(C,D,A,B,X( 7),16,0xf6bb4b60L);
|
||||
R2(B,C,D,A,X(10),23,0xbebfbc70L);
|
||||
R2(A,B,C,D,X(13), 4,0x289b7ec6L);
|
||||
R2(D,A,B,C,X( 0),11,0xeaa127faL);
|
||||
R2(C,D,A,B,X( 3),16,0xd4ef3085L);
|
||||
R2(B,C,D,A,X( 6),23,0x04881d05L);
|
||||
R2(A,B,C,D,X( 9), 4,0xd9d4d039L);
|
||||
R2(D,A,B,C,X(12),11,0xe6db99e5L);
|
||||
R2(C,D,A,B,X(15),16,0x1fa27cf8L);
|
||||
R2(B,C,D,A,X( 2),23,0xc4ac5665L);
|
||||
/* Round 3 */
|
||||
R3(A,B,C,D,X( 0), 6,0xf4292244L);
|
||||
R3(D,A,B,C,X( 7),10,0x432aff97L);
|
||||
R3(C,D,A,B,X(14),15,0xab9423a7L);
|
||||
R3(B,C,D,A,X( 5),21,0xfc93a039L);
|
||||
R3(A,B,C,D,X(12), 6,0x655b59c3L);
|
||||
R3(D,A,B,C,X( 3),10,0x8f0ccc92L);
|
||||
R3(C,D,A,B,X(10),15,0xffeff47dL);
|
||||
R3(B,C,D,A,X( 1),21,0x85845dd1L);
|
||||
R3(A,B,C,D,X( 8), 6,0x6fa87e4fL);
|
||||
R3(D,A,B,C,X(15),10,0xfe2ce6e0L);
|
||||
R3(C,D,A,B,X( 6),15,0xa3014314L);
|
||||
R3(B,C,D,A,X(13),21,0x4e0811a1L);
|
||||
R3(A,B,C,D,X( 4), 6,0xf7537e82L);
|
||||
R3(D,A,B,C,X(11),10,0xbd3af235L);
|
||||
R3(C,D,A,B,X( 2),15,0x2ad7d2bbL);
|
||||
R3(B,C,D,A,X( 9),21,0xeb86d391L);
|
||||
|
||||
A = c->A += A;
|
||||
B = c->B += B;
|
||||
C = c->C += C;
|
||||
D = c->D += D;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef undef
|
||||
int printit(unsigned long *l)
|
||||
{
|
||||
int i,ii;
|
||||
|
||||
for (i=0; i<2; i++)
|
||||
{
|
||||
for (ii=0; ii<8; ii++)
|
||||
{
|
||||
fprintf(stderr,"%08lx ",l[i*8+ii]);
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
}
|
||||
#endif
|
176
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/md5/md5_locl.h
Executable file
176
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/md5/md5_locl.h
Executable file
@ -0,0 +1,176 @@
|
||||
/* crypto/md5/md5_locl.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <openssl/e_os2.h>
|
||||
#include <openssl/md5.h>
|
||||
|
||||
#ifndef MD5_LONG_LOG2
|
||||
#define MD5_LONG_LOG2 2 /* default to 32 bits */
|
||||
#endif
|
||||
|
||||
#ifdef MD5_ASM
|
||||
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__) || defined(__x86_64) || defined(__x86_64__)
|
||||
# if !defined(B_ENDIAN)
|
||||
# define md5_block_host_order md5_block_asm_host_order
|
||||
# endif
|
||||
# elif defined(__sparc) && defined(OPENSSL_SYS_ULTRASPARC)
|
||||
void md5_block_asm_data_order_aligned (MD5_CTX *c, const MD5_LONG *p,size_t num);
|
||||
# define HASH_BLOCK_DATA_ORDER_ALIGNED md5_block_asm_data_order_aligned
|
||||
# endif
|
||||
#endif
|
||||
|
||||
void md5_block_host_order (MD5_CTX *c, const void *p,size_t num);
|
||||
void md5_block_data_order (MD5_CTX *c, const void *p,size_t num);
|
||||
|
||||
#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__) || defined(__x86_64) || defined(__x86_64__)
|
||||
# if !defined(B_ENDIAN)
|
||||
/*
|
||||
* *_block_host_order is expected to handle aligned data while
|
||||
* *_block_data_order - unaligned. As algorithm and host (x86)
|
||||
* are in this case of the same "endianness" these two are
|
||||
* otherwise indistinguishable. But normally you don't want to
|
||||
* call the same function because unaligned access in places
|
||||
* where alignment is expected is usually a "Bad Thing". Indeed,
|
||||
* on RISCs you get punished with BUS ERROR signal or *severe*
|
||||
* performance degradation. Intel CPUs are in turn perfectly
|
||||
* capable of loading unaligned data without such drastic side
|
||||
* effect. Yes, they say it's slower than aligned load, but no
|
||||
* exception is generated and therefore performance degradation
|
||||
* is *incomparable* with RISCs. What we should weight here is
|
||||
* costs of unaligned access against costs of aligning data.
|
||||
* According to my measurements allowing unaligned access results
|
||||
* in ~9% performance improvement on Pentium II operating at
|
||||
* 266MHz. I won't be surprised if the difference will be higher
|
||||
* on faster systems:-)
|
||||
*
|
||||
* <appro@fy.chalmers.se>
|
||||
*/
|
||||
# define md5_block_data_order md5_block_host_order
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define DATA_ORDER_IS_LITTLE_ENDIAN
|
||||
|
||||
#define HASH_LONG MD5_LONG
|
||||
#define HASH_LONG_LOG2 MD5_LONG_LOG2
|
||||
#define HASH_CTX MD5_CTX
|
||||
#define HASH_CBLOCK MD5_CBLOCK
|
||||
#define HASH_LBLOCK MD5_LBLOCK
|
||||
#define HASH_UPDATE MD5_Update
|
||||
#define HASH_TRANSFORM MD5_Transform
|
||||
#define HASH_FINAL MD5_Final
|
||||
#define HASH_MAKE_STRING(c,s) do { \
|
||||
unsigned long ll; \
|
||||
ll=(c)->A; HOST_l2c(ll,(s)); \
|
||||
ll=(c)->B; HOST_l2c(ll,(s)); \
|
||||
ll=(c)->C; HOST_l2c(ll,(s)); \
|
||||
ll=(c)->D; HOST_l2c(ll,(s)); \
|
||||
} while (0)
|
||||
#define HASH_BLOCK_HOST_ORDER md5_block_host_order
|
||||
#if !defined(L_ENDIAN) || defined(md5_block_data_order)
|
||||
#define HASH_BLOCK_DATA_ORDER md5_block_data_order
|
||||
/*
|
||||
* Little-endians (Intel and Alpha) feel better without this.
|
||||
* It looks like memcpy does better job than generic
|
||||
* md5_block_data_order on copying-n-aligning input data.
|
||||
* But frankly speaking I didn't expect such result on Alpha.
|
||||
* On the other hand I've got this with egcs-1.0.2 and if
|
||||
* program is compiled with another (better?) compiler it
|
||||
* might turn out other way around.
|
||||
*
|
||||
* <appro@fy.chalmers.se>
|
||||
*/
|
||||
#endif
|
||||
|
||||
#include "md32_common.h"
|
||||
|
||||
/*
|
||||
#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
|
||||
#define G(x,y,z) (((x) & (z)) | ((y) & (~(z))))
|
||||
*/
|
||||
|
||||
/* As pointed out by Wei Dai <weidai@eskimo.com>, the above can be
|
||||
* simplified to the code below. Wei attributes these optimizations
|
||||
* to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel.
|
||||
*/
|
||||
#define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
|
||||
#define G(b,c,d) ((((b) ^ (c)) & (d)) ^ (c))
|
||||
#define H(b,c,d) ((b) ^ (c) ^ (d))
|
||||
#define I(b,c,d) (((~(d)) | (b)) ^ (c))
|
||||
|
||||
#define R0(a,b,c,d,k,s,t) { \
|
||||
a+=((k)+(t)+F((b),(c),(d))); \
|
||||
a=ROTATE(a,s); \
|
||||
a+=b; };\
|
||||
|
||||
#define R1(a,b,c,d,k,s,t) { \
|
||||
a+=((k)+(t)+G((b),(c),(d))); \
|
||||
a=ROTATE(a,s); \
|
||||
a+=b; };
|
||||
|
||||
#define R2(a,b,c,d,k,s,t) { \
|
||||
a+=((k)+(t)+H((b),(c),(d))); \
|
||||
a=ROTATE(a,s); \
|
||||
a+=b; };
|
||||
|
||||
#define R3(a,b,c,d,k,s,t) { \
|
||||
a+=((k)+(t)+I((b),(c),(d))); \
|
||||
a=ROTATE(a,s); \
|
||||
a+=b; };
|
97
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/md5/md5_one.c
Executable file
97
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/md5/md5_one.c
Executable file
@ -0,0 +1,97 @@
|
||||
/* crypto/md5/md5_one.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
#ifdef CHARSET_EBCDIC
|
||||
#include <openssl/ebcdic.h>
|
||||
#endif
|
||||
|
||||
unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md)
|
||||
{
|
||||
MD5_CTX c;
|
||||
static unsigned char m[MD5_DIGEST_LENGTH];
|
||||
|
||||
if (md == NULL) md=m;
|
||||
if (!MD5_Init(&c))
|
||||
return NULL;
|
||||
#ifndef CHARSET_EBCDIC
|
||||
MD5_Update(&c,d,n);
|
||||
#else
|
||||
{
|
||||
char temp[1024];
|
||||
unsigned long chunk;
|
||||
|
||||
while (n > 0)
|
||||
{
|
||||
chunk = (n > sizeof(temp)) ? sizeof(temp) : n;
|
||||
ebcdic2ascii(temp, d, chunk);
|
||||
MD5_Update(&c,temp,chunk);
|
||||
n -= chunk;
|
||||
d += chunk;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
MD5_Final(md,&c);
|
||||
OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */
|
||||
return(md);
|
||||
}
|
||||
|
404
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/mem.c
Executable file
404
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/mem.c
Executable file
@ -0,0 +1,404 @@
|
||||
/* crypto/mem.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/cryptlib.h>
|
||||
|
||||
/*Begin: 17Aug2006, Chris */
|
||||
//#include "utility.h" //for debug sean
|
||||
/*End: 17Aug2006, Chris */
|
||||
|
||||
static int allow_customize = 1; /* we provide flexible functions for */
|
||||
static int allow_customize_debug = 1;/* exchanging memory-related functions at
|
||||
* run-time, but this must be done
|
||||
* before any blocks are actually
|
||||
* allocated; or we'll run into huge
|
||||
* problems when malloc/free pairs
|
||||
* don't match etc. */
|
||||
|
||||
|
||||
|
||||
/* the following pointers may be changed as long as 'allow_customize' is set */
|
||||
|
||||
static void *(*malloc_func)(size_t) = malloc;
|
||||
static void *default_malloc_ex(size_t num, const char *file, int line)
|
||||
{ return malloc_func(num); }
|
||||
static void *(*malloc_ex_func)(size_t, const char *file, int line)
|
||||
= default_malloc_ex;
|
||||
|
||||
static void *(*realloc_func)(void *, size_t)= realloc;
|
||||
static void *default_realloc_ex(void *str, size_t num,
|
||||
const char *file, int line)
|
||||
{ return realloc_func(str,num); }
|
||||
static void *(*realloc_ex_func)(void *, size_t, const char *file, int line)
|
||||
= default_realloc_ex;
|
||||
|
||||
static void (*free_func)(void *) = free;
|
||||
|
||||
static void *(*malloc_locked_func)(size_t) = malloc;
|
||||
static void *default_malloc_locked_ex(size_t num, const char *file, int line)
|
||||
{ return malloc_locked_func(num); }
|
||||
static void *(*malloc_locked_ex_func)(size_t, const char *file, int line)
|
||||
= default_malloc_locked_ex;
|
||||
|
||||
static void (*free_locked_func)(void *) = free;
|
||||
|
||||
|
||||
|
||||
/* may be changed as long as 'allow_customize_debug' is set */
|
||||
/* XXX use correct function pointer types */
|
||||
#ifdef CRYPTO_MDEBUG
|
||||
/* use default functions from mem_dbg.c */
|
||||
static void (*malloc_debug_func)(void *,int,const char *,int,int)
|
||||
= CRYPTO_dbg_malloc;
|
||||
static void (*realloc_debug_func)(void *,void *,int,const char *,int,int)
|
||||
= CRYPTO_dbg_realloc;
|
||||
static void (*free_debug_func)(void *,int) = CRYPTO_dbg_free;
|
||||
static void (*set_debug_options_func)(long) = CRYPTO_dbg_set_options;
|
||||
static long (*get_debug_options_func)(void) = CRYPTO_dbg_get_options;
|
||||
#else
|
||||
/* applications can use CRYPTO_malloc_debug_init() to select above case
|
||||
* at run-time */
|
||||
static void (*malloc_debug_func)(void *,int,const char *,int,int) = NULL;
|
||||
static void (*realloc_debug_func)(void *,void *,int,const char *,int,int)
|
||||
= NULL;
|
||||
static void (*free_debug_func)(void *,int) = NULL;
|
||||
static void (*set_debug_options_func)(long) = NULL;
|
||||
static long (*get_debug_options_func)(void) = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
int CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t),
|
||||
void (*f)(void *))
|
||||
{
|
||||
if (!allow_customize)
|
||||
return 0;
|
||||
if ((m == 0) || (r == 0) || (f == 0))
|
||||
return 0;
|
||||
malloc_func=m; malloc_ex_func=default_malloc_ex;
|
||||
realloc_func=r; realloc_ex_func=default_realloc_ex;
|
||||
free_func=f;
|
||||
malloc_locked_func=m; malloc_locked_ex_func=default_malloc_locked_ex;
|
||||
free_locked_func=f;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CRYPTO_set_mem_ex_functions(
|
||||
void *(*m)(size_t,const char *,int),
|
||||
void *(*r)(void *, size_t,const char *,int),
|
||||
void (*f)(void *))
|
||||
{
|
||||
if (!allow_customize)
|
||||
return 0;
|
||||
if ((m == 0) || (r == 0) || (f == 0))
|
||||
return 0;
|
||||
malloc_func=0; malloc_ex_func=m;
|
||||
realloc_func=0; realloc_ex_func=r;
|
||||
free_func=f;
|
||||
malloc_locked_func=0; malloc_locked_ex_func=m;
|
||||
free_locked_func=f;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*f)(void *))
|
||||
{
|
||||
if (!allow_customize)
|
||||
return 0;
|
||||
if ((m == NULL) || (f == NULL))
|
||||
return 0;
|
||||
malloc_locked_func=m; malloc_locked_ex_func=default_malloc_locked_ex;
|
||||
free_locked_func=f;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CRYPTO_set_locked_mem_ex_functions(
|
||||
void *(*m)(size_t,const char *,int),
|
||||
void (*f)(void *))
|
||||
{
|
||||
if (!allow_customize)
|
||||
return 0;
|
||||
if ((m == NULL) || (f == NULL))
|
||||
return 0;
|
||||
malloc_locked_func=0; malloc_locked_ex_func=m;
|
||||
free_func=f;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
|
||||
void (*r)(void *,void *,int,const char *,int,int),
|
||||
void (*f)(void *,int),
|
||||
void (*so)(long),
|
||||
long (*go)(void))
|
||||
{
|
||||
if (!allow_customize_debug)
|
||||
return 0;
|
||||
malloc_debug_func=m;
|
||||
realloc_debug_func=r;
|
||||
free_debug_func=f;
|
||||
set_debug_options_func=so;
|
||||
get_debug_options_func=go;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
|
||||
void (**f)(void *))
|
||||
{
|
||||
if (m != NULL) *m = (malloc_ex_func == default_malloc_ex) ?
|
||||
malloc_func : 0;
|
||||
if (r != NULL) *r = (realloc_ex_func == default_realloc_ex) ?
|
||||
realloc_func : 0;
|
||||
if (f != NULL) *f=free_func;
|
||||
}
|
||||
|
||||
void CRYPTO_get_mem_ex_functions(
|
||||
void *(**m)(size_t,const char *,int),
|
||||
void *(**r)(void *, size_t,const char *,int),
|
||||
void (**f)(void *))
|
||||
{
|
||||
if (m != NULL) *m = (malloc_ex_func != default_malloc_ex) ?
|
||||
malloc_ex_func : 0;
|
||||
if (r != NULL) *r = (realloc_ex_func != default_realloc_ex) ?
|
||||
realloc_ex_func : 0;
|
||||
if (f != NULL) *f=free_func;
|
||||
}
|
||||
|
||||
void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *))
|
||||
{
|
||||
if (m != NULL) *m = (malloc_locked_ex_func == default_malloc_locked_ex) ?
|
||||
malloc_locked_func : 0;
|
||||
if (f != NULL) *f=free_locked_func;
|
||||
}
|
||||
|
||||
void CRYPTO_get_locked_mem_ex_functions(
|
||||
void *(**m)(size_t,const char *,int),
|
||||
void (**f)(void *))
|
||||
{
|
||||
if (m != NULL) *m = (malloc_locked_ex_func != default_malloc_locked_ex) ?
|
||||
malloc_locked_ex_func : 0;
|
||||
if (f != NULL) *f=free_locked_func;
|
||||
}
|
||||
|
||||
void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
|
||||
void (**r)(void *,void *,int,const char *,int,int),
|
||||
void (**f)(void *,int),
|
||||
void (**so)(long),
|
||||
long (**go)(void))
|
||||
{
|
||||
if (m != NULL) *m=malloc_debug_func;
|
||||
if (r != NULL) *r=realloc_debug_func;
|
||||
if (f != NULL) *f=free_debug_func;
|
||||
if (so != NULL) *so=set_debug_options_func;
|
||||
if (go != NULL) *go=get_debug_options_func;
|
||||
}
|
||||
|
||||
|
||||
void *CRYPTO_malloc_locked(int num, const char *file, int line)
|
||||
{
|
||||
void *ret = NULL;
|
||||
extern unsigned char cleanse_ctr;
|
||||
|
||||
if (num <= 0) return NULL;
|
||||
|
||||
allow_customize = 0;
|
||||
if (malloc_debug_func != NULL)
|
||||
{
|
||||
allow_customize_debug = 0;
|
||||
malloc_debug_func(NULL, num, file, line, 0);
|
||||
}
|
||||
ret = malloc_locked_ex_func(num,file,line);
|
||||
#ifdef LEVITTE_DEBUG_MEM
|
||||
fprintf(stderr, "LEVITTE_DEBUG_MEM: > 0x%p (%d)\n", ret, num);
|
||||
#endif
|
||||
if (malloc_debug_func != NULL)
|
||||
malloc_debug_func(ret, num, file, line, 1);
|
||||
|
||||
/* Create a dependency on the value of 'cleanse_ctr' so our memory
|
||||
* sanitisation function can't be optimised out. NB: We only do
|
||||
* this for >2Kb so the overhead doesn't bother us. */
|
||||
if(ret && (num > 2048))
|
||||
((unsigned char *)ret)[0] = cleanse_ctr;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CRYPTO_free_locked(void *str)
|
||||
{
|
||||
if (free_debug_func != NULL)
|
||||
free_debug_func(str, 0);
|
||||
#ifdef LEVITTE_DEBUG_MEM
|
||||
fprintf(stderr, "LEVITTE_DEBUG_MEM: < 0x%p\n", str);
|
||||
#endif
|
||||
free_locked_func(str);
|
||||
if (free_debug_func != NULL)
|
||||
free_debug_func(NULL, 1);
|
||||
}
|
||||
|
||||
void *CRYPTO_malloc(int num, const char *file, int line)
|
||||
{
|
||||
void *ret = NULL;
|
||||
extern unsigned char cleanse_ctr;
|
||||
|
||||
if (num <= 0) return NULL;
|
||||
|
||||
allow_customize = 0;
|
||||
if (malloc_debug_func != NULL)
|
||||
{
|
||||
allow_customize_debug = 0;
|
||||
malloc_debug_func(NULL, num, file, line, 0);
|
||||
}
|
||||
ret = malloc_ex_func(num,file,line);
|
||||
#ifdef LEVITTE_DEBUG_MEM
|
||||
fprintf(stderr, "LEVITTE_DEBUG_MEM: > 0x%p (%d)\n", ret, num);
|
||||
#endif
|
||||
if (malloc_debug_func != NULL)
|
||||
malloc_debug_func(ret, num, file, line, 1);
|
||||
|
||||
/* Create a dependency on the value of 'cleanse_ctr' so our memory
|
||||
* sanitisation function can't be optimised out. NB: We only do
|
||||
* this for >2Kb so the overhead doesn't bother us. */
|
||||
if(ret && (num > 2048))
|
||||
((unsigned char *)ret)[0] = cleanse_ctr;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *CRYPTO_realloc(void *str, int num, const char *file, int line)
|
||||
{
|
||||
void *ret = NULL;
|
||||
|
||||
if (str == NULL)
|
||||
return CRYPTO_malloc(num, file, line);
|
||||
|
||||
if (num <= 0) return NULL;
|
||||
|
||||
if (realloc_debug_func != NULL)
|
||||
realloc_debug_func(str, NULL, num, file, line, 0);
|
||||
ret = realloc_ex_func(str,num,file,line);
|
||||
#ifdef LEVITTE_DEBUG_MEM
|
||||
fprintf(stderr, "LEVITTE_DEBUG_MEM: | 0x%p -> 0x%p (%d)\n", str, ret, num);
|
||||
#endif
|
||||
if (realloc_debug_func != NULL)
|
||||
realloc_debug_func(str, ret, num, file, line, 1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file,
|
||||
int line)
|
||||
{
|
||||
void *ret = NULL;
|
||||
|
||||
if (str == NULL)
|
||||
return CRYPTO_malloc(num, file, line);
|
||||
|
||||
if (num <= 0) return NULL;
|
||||
|
||||
if (realloc_debug_func != NULL)
|
||||
realloc_debug_func(str, NULL, num, file, line, 0);
|
||||
ret=malloc_ex_func(num,file,line);
|
||||
if(ret)
|
||||
{
|
||||
memcpy(ret,str,old_len);
|
||||
OPENSSL_cleanse(str,old_len);
|
||||
free_func(str);
|
||||
}
|
||||
#ifdef LEVITTE_DEBUG_MEM
|
||||
fprintf(stderr,
|
||||
"LEVITTE_DEBUG_MEM: | 0x%p -> 0x%p (%d)\n",
|
||||
str, ret, num);
|
||||
#endif
|
||||
if (realloc_debug_func != NULL)
|
||||
realloc_debug_func(str, ret, num, file, line, 1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CRYPTO_free(void *str)
|
||||
{
|
||||
if (free_debug_func != NULL)
|
||||
free_debug_func(str, 0);
|
||||
#ifdef LEVITTE_DEBUG_MEM
|
||||
fprintf(stderr, "LEVITTE_DEBUG_MEM: < 0x%p\n", str);
|
||||
#endif
|
||||
free_func(str);
|
||||
if (free_debug_func != NULL)
|
||||
free_debug_func(NULL, 1);
|
||||
}
|
||||
|
||||
void *CRYPTO_remalloc(void *a, int num, const char *file, int line)
|
||||
{
|
||||
if (a != NULL) OPENSSL_free(a);
|
||||
a=(char *)OPENSSL_malloc(num);
|
||||
return(a);
|
||||
}
|
||||
|
||||
void CRYPTO_set_mem_debug_options(long bits)
|
||||
{
|
||||
if (set_debug_options_func != NULL)
|
||||
set_debug_options_func(bits);
|
||||
}
|
||||
|
||||
long CRYPTO_get_mem_debug_options(void)
|
||||
{
|
||||
if (get_debug_options_func != NULL)
|
||||
return get_debug_options_func();
|
||||
return 0;
|
||||
}
|
75
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/mem_clr.c
Executable file
75
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/mem_clr.c
Executable file
@ -0,0 +1,75 @@
|
||||
/* crypto/mem_clr.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
|
||||
* project 2002.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2001 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).
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
unsigned char cleanse_ctr = 0;
|
||||
|
||||
void OPENSSL_cleanse(void *ptr, size_t len)
|
||||
{
|
||||
unsigned char *p = ptr;
|
||||
size_t loop = len;
|
||||
while(loop--)
|
||||
{
|
||||
*(p++) = cleanse_ctr;
|
||||
cleanse_ctr += (17 + (unsigned char)((unsigned long)p & 0xF));
|
||||
}
|
||||
if(memchr(ptr, cleanse_ctr, len))
|
||||
cleanse_ctr += 63;
|
||||
}
|
690
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/rand/md_rand.c
Executable file
690
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/rand/md_rand.c
Executable file
@ -0,0 +1,690 @@
|
||||
/* crypto/rand/md_rand.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2001 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).
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef MD_RAND_DEBUG
|
||||
# ifndef NDEBUG
|
||||
# define NDEBUG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#include <assert.h>
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
/*Begin: 17Aug2006, Chris */
|
||||
//#include "utility.h"
|
||||
#define assert
|
||||
#ifdef RSDK_BUILT
|
||||
#define PRIVATE_RAND_ENGINE 1
|
||||
#else
|
||||
#define PRIVATE_RAND_ENGINE 0
|
||||
#endif
|
||||
/*End: 17Aug2006, Chris */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#include "e_os.h"
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
#include <openssl/rand.h>
|
||||
#include "rand_lcl.h"
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#include <openssl/err.h>
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
/*Begin: a dummy function instead of involving other souce files, 17Aug2006, Chris */
|
||||
unsigned long CRYPTO_thread_id(void){return 0;};
|
||||
int RAND_poll(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*End: a dummy function instead of involving other souce files, 17Aug2006, Chris */
|
||||
|
||||
#ifdef BN_DEBUG
|
||||
# define PREDICT
|
||||
#endif
|
||||
|
||||
/* #define PREDICT 1 */
|
||||
|
||||
#if (PRIVATE_RAND_ENGINE==1)
|
||||
static void my_ssleay_rand_seed(const void *buf, int num);
|
||||
static int my_ssleay_rand_bytes(unsigned char *buf, int num);
|
||||
static void my_ssleay_rand_cleanup(void);
|
||||
static void my_ssleay_rand_add(const void *buf, int num, int add);
|
||||
static int my_ssleay_rand_pseudo_bytes(unsigned char *buf, int num) ;
|
||||
static int my_ssleay_rand_status(void);
|
||||
|
||||
RAND_METHOD rand_ssleay_meth={
|
||||
my_ssleay_rand_seed,
|
||||
my_ssleay_rand_bytes,
|
||||
my_ssleay_rand_cleanup,
|
||||
my_ssleay_rand_add,
|
||||
my_ssleay_rand_pseudo_bytes,
|
||||
my_ssleay_rand_status
|
||||
};
|
||||
RAND_METHOD *RAND_SSLeay(void)
|
||||
{
|
||||
return(&rand_ssleay_meth);
|
||||
}
|
||||
|
||||
static int initialized=0;
|
||||
void rand_initialize(void)
|
||||
{
|
||||
}
|
||||
int get_random_bytes(unsigned char *buf, int num)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<num;i++)
|
||||
buf[i]=0x55; //rand()??
|
||||
return 1;
|
||||
}
|
||||
static void my_ssleay_rand_seed(const void *buf, int num)
|
||||
{
|
||||
return; //dummy
|
||||
}
|
||||
|
||||
static int my_ssleay_rand_bytes(unsigned char *buf, int num)
|
||||
{
|
||||
return get_random_bytes(buf,num);
|
||||
}
|
||||
|
||||
static void my_ssleay_rand_cleanup(void)
|
||||
{
|
||||
initialized=0;
|
||||
}
|
||||
|
||||
static void my_ssleay_rand_add(const void *buf, int num, int add)
|
||||
{
|
||||
if (!initialized)
|
||||
{
|
||||
rand_initialize();
|
||||
initialized=1;
|
||||
}
|
||||
}
|
||||
|
||||
static int my_ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
|
||||
{
|
||||
return get_random_bytes(buf,num);
|
||||
}
|
||||
static int my_ssleay_rand_status(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#else //PRIVATE_RAND_ENGINE
|
||||
#define STATE_SIZE 1023
|
||||
static int state_num=0,state_index=0;
|
||||
static unsigned char state[STATE_SIZE+MD_DIGEST_LENGTH];
|
||||
static unsigned char md[MD_DIGEST_LENGTH];
|
||||
static long md_count[2]={0,0};
|
||||
static int entropy=0;
|
||||
static int initialized=0;
|
||||
|
||||
static unsigned int crypto_lock_rand = 0; /* may be set only when a thread
|
||||
* holds CRYPTO_LOCK_RAND
|
||||
* (to prevent double locking) */
|
||||
/* access to lockin_thread is synchronized by CRYPTO_LOCK_RAND2 */
|
||||
static unsigned long locking_thread = 0; /* valid iff crypto_lock_rand is set */
|
||||
|
||||
|
||||
#ifdef PREDICT
|
||||
int rand_predictable=0;
|
||||
#endif
|
||||
|
||||
const char *RAND_version="RAND" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
static void ssleay_rand_cleanup(void);
|
||||
static void ssleay_rand_seed(const void *buf, int num);
|
||||
/*Begin: don't not support double , 17Aug2006, Chris */
|
||||
#ifdef RSDK_BUILT
|
||||
static void ssleay_rand_add(const void *buf, int num, int add_entropy);
|
||||
#else
|
||||
static void ssleay_rand_add(const void *buf, int num, double add_entropy);
|
||||
#endif
|
||||
/*End: don't not support double , 17Aug2006, Chris */
|
||||
static int ssleay_rand_bytes(unsigned char *buf, int num);
|
||||
static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num);
|
||||
static int ssleay_rand_status(void);
|
||||
RAND_METHOD rand_ssleay_meth={
|
||||
ssleay_rand_seed,
|
||||
ssleay_rand_bytes,
|
||||
ssleay_rand_cleanup,
|
||||
ssleay_rand_add,
|
||||
ssleay_rand_pseudo_bytes,
|
||||
ssleay_rand_status
|
||||
};
|
||||
RAND_METHOD *RAND_SSLeay(void)
|
||||
{
|
||||
return(&rand_ssleay_meth);
|
||||
}
|
||||
static void ssleay_rand_cleanup(void)
|
||||
{
|
||||
OPENSSL_cleanse(state,sizeof(state));
|
||||
state_num=0;
|
||||
state_index=0;
|
||||
OPENSSL_cleanse(md,MD_DIGEST_LENGTH);
|
||||
md_count[0]=0;
|
||||
md_count[1]=0;
|
||||
entropy=0;
|
||||
initialized=0;
|
||||
}
|
||||
/*Begin: don't not support double , 17Aug2006, Chris */
|
||||
#ifdef RSDK_BUILT
|
||||
static void ssleay_rand_add(const void *buf, int num, int add)
|
||||
#else
|
||||
static void ssleay_rand_add(const void *buf, int num, double add)
|
||||
#endif
|
||||
/*End: don't not support double , 17Aug2006, Chris */
|
||||
{
|
||||
int i,j,k,st_idx;
|
||||
long md_c[2];
|
||||
unsigned char local_md[MD_DIGEST_LENGTH];
|
||||
EVP_MD_CTX m;
|
||||
int do_not_lock;
|
||||
|
||||
/*
|
||||
* (Based on the rand(3) manpage)
|
||||
*
|
||||
* The input is chopped up into units of 20 bytes (or less for
|
||||
* the last block). Each of these blocks is run through the hash
|
||||
* function as follows: The data passed to the hash function
|
||||
* is the current 'md', the same number of bytes from the 'state'
|
||||
* (the location determined by in incremented looping index) as
|
||||
* the current 'block', the new key data 'block', and 'count'
|
||||
* (which is incremented after each use).
|
||||
* The result of this is kept in 'md' and also xored into the
|
||||
* 'state' at the same locations that were used as input into the
|
||||
* hash function.
|
||||
*/
|
||||
|
||||
/* check if we already have the lock */
|
||||
if (crypto_lock_rand)
|
||||
{
|
||||
CRYPTO_r_lock(CRYPTO_LOCK_RAND2);
|
||||
do_not_lock = (locking_thread == CRYPTO_thread_id());
|
||||
CRYPTO_r_unlock(CRYPTO_LOCK_RAND2);
|
||||
}
|
||||
else
|
||||
do_not_lock = 0;
|
||||
|
||||
if (!do_not_lock) CRYPTO_w_lock(CRYPTO_LOCK_RAND);
|
||||
st_idx=state_index;
|
||||
|
||||
/* use our own copies of the counters so that even
|
||||
* if a concurrent thread seeds with exactly the
|
||||
* same data and uses the same subarray there's _some_
|
||||
* difference */
|
||||
md_c[0] = md_count[0];
|
||||
md_c[1] = md_count[1];
|
||||
|
||||
memcpy(local_md, md, sizeof md);
|
||||
|
||||
/* state_index <= state_num <= STATE_SIZE */
|
||||
state_index += num;
|
||||
if (state_index >= STATE_SIZE)
|
||||
{
|
||||
state_index%=STATE_SIZE;
|
||||
state_num=STATE_SIZE;
|
||||
}
|
||||
else if (state_num < STATE_SIZE)
|
||||
{
|
||||
if (state_index > state_num)
|
||||
state_num=state_index;
|
||||
}
|
||||
/* state_index <= state_num <= STATE_SIZE */
|
||||
|
||||
/* state[st_idx], ..., state[(st_idx + num - 1) % STATE_SIZE]
|
||||
* are what we will use now, but other threads may use them
|
||||
* as well */
|
||||
|
||||
md_count[1] += (num / MD_DIGEST_LENGTH) + (num % MD_DIGEST_LENGTH > 0);
|
||||
|
||||
if (!do_not_lock) CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
|
||||
|
||||
EVP_MD_CTX_init(&m);
|
||||
for (i=0; i<num; i+=MD_DIGEST_LENGTH)
|
||||
{
|
||||
j=(num-i);
|
||||
j=(j > MD_DIGEST_LENGTH)?MD_DIGEST_LENGTH:j;
|
||||
|
||||
MD_Init(&m);
|
||||
MD_Update(&m,local_md,MD_DIGEST_LENGTH);
|
||||
k=(st_idx+j)-STATE_SIZE;
|
||||
if (k > 0)
|
||||
{
|
||||
MD_Update(&m,&(state[st_idx]),j-k);
|
||||
MD_Update(&m,&(state[0]),k);
|
||||
}
|
||||
else
|
||||
MD_Update(&m,&(state[st_idx]),j);
|
||||
|
||||
MD_Update(&m,buf,j);
|
||||
MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
|
||||
MD_Final(&m,local_md);
|
||||
md_c[1]++;
|
||||
|
||||
buf=(const char *)buf + j;
|
||||
|
||||
for (k=0; k<j; k++)
|
||||
{
|
||||
/* Parallel threads may interfere with this,
|
||||
* but always each byte of the new state is
|
||||
* the XOR of some previous value of its
|
||||
* and local_md (itermediate values may be lost).
|
||||
* Alway using locking could hurt performance more
|
||||
* than necessary given that conflicts occur only
|
||||
* when the total seeding is longer than the random
|
||||
* state. */
|
||||
state[st_idx++]^=local_md[k];
|
||||
if (st_idx >= STATE_SIZE)
|
||||
st_idx=0;
|
||||
}
|
||||
}
|
||||
EVP_MD_CTX_cleanup(&m);
|
||||
|
||||
if (!do_not_lock) CRYPTO_w_lock(CRYPTO_LOCK_RAND);
|
||||
/* Don't just copy back local_md into md -- this could mean that
|
||||
* other thread's seeding remains without effect (except for
|
||||
* the incremented counter). By XORing it we keep at least as
|
||||
* much entropy as fits into md. */
|
||||
for (k = 0; k < (int)sizeof(md); k++)
|
||||
{
|
||||
md[k] ^= local_md[k];
|
||||
}
|
||||
if (entropy < ENTROPY_NEEDED) /* stop counting when we have enough */
|
||||
entropy += add;
|
||||
if (!do_not_lock) CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
|
||||
|
||||
#if !defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32)
|
||||
assert(md_c[1] == md_count[1]);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ssleay_rand_seed(const void *buf, int num)
|
||||
{
|
||||
ssleay_rand_add(buf, num, (double)num);
|
||||
}
|
||||
|
||||
static int ssleay_rand_bytes(unsigned char *buf, int num)
|
||||
{
|
||||
static volatile int stirred_pool = 0;
|
||||
int i,j,k,st_num,st_idx;
|
||||
int num_ceil;
|
||||
int ok;
|
||||
long md_c[2];
|
||||
unsigned char local_md[MD_DIGEST_LENGTH];
|
||||
EVP_MD_CTX m;
|
||||
#ifndef GETPID_IS_MEANINGLESS
|
||||
pid_t curr_pid = getpid();
|
||||
#endif
|
||||
int do_stir_pool = 0;
|
||||
|
||||
#ifdef PREDICT
|
||||
if (rand_predictable)
|
||||
{
|
||||
static unsigned char val=0;
|
||||
|
||||
for (i=0; i<num; i++)
|
||||
buf[i]=val++;
|
||||
return(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (num <= 0)
|
||||
return 1;
|
||||
|
||||
EVP_MD_CTX_init(&m);
|
||||
/* round upwards to multiple of MD_DIGEST_LENGTH/2 */
|
||||
num_ceil = (1 + (num-1)/(MD_DIGEST_LENGTH/2)) * (MD_DIGEST_LENGTH/2);
|
||||
|
||||
/*
|
||||
* (Based on the rand(3) manpage:)
|
||||
*
|
||||
* For each group of 10 bytes (or less), we do the following:
|
||||
*
|
||||
* Input into the hash function the local 'md' (which is initialized from
|
||||
* the global 'md' before any bytes are generated), the bytes that are to
|
||||
* be overwritten by the random bytes, and bytes from the 'state'
|
||||
* (incrementing looping index). From this digest output (which is kept
|
||||
* in 'md'), the top (up to) 10 bytes are returned to the caller and the
|
||||
* bottom 10 bytes are xored into the 'state'.
|
||||
*
|
||||
* Finally, after we have finished 'num' random bytes for the
|
||||
* caller, 'count' (which is incremented) and the local and global 'md'
|
||||
* are fed into the hash function and the results are kept in the
|
||||
* global 'md'.
|
||||
*/
|
||||
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_RAND);
|
||||
|
||||
/* prevent ssleay_rand_bytes() from trying to obtain the lock again */
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_RAND2);
|
||||
locking_thread = CRYPTO_thread_id();
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_RAND2);
|
||||
crypto_lock_rand = 1;
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
RAND_poll();
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
if (!stirred_pool)
|
||||
do_stir_pool = 1;
|
||||
|
||||
ok = (entropy >= ENTROPY_NEEDED);
|
||||
if (!ok)
|
||||
{
|
||||
/* If the PRNG state is not yet unpredictable, then seeing
|
||||
* the PRNG output may help attackers to determine the new
|
||||
* state; thus we have to decrease the entropy estimate.
|
||||
* Once we've had enough initial seeding we don't bother to
|
||||
* adjust the entropy count, though, because we're not ambitious
|
||||
* to provide *information-theoretic* randomness.
|
||||
*
|
||||
* NOTE: This approach fails if the program forks before
|
||||
* we have enough entropy. Entropy should be collected
|
||||
* in a separate input pool and be transferred to the
|
||||
* output pool only when the entropy limit has been reached.
|
||||
*/
|
||||
entropy -= num;
|
||||
if (entropy < 0)
|
||||
entropy = 0;
|
||||
}
|
||||
|
||||
if (do_stir_pool)
|
||||
{
|
||||
/* In the output function only half of 'md' remains secret,
|
||||
* so we better make sure that the required entropy gets
|
||||
* 'evenly distributed' through 'state', our randomness pool.
|
||||
* The input function (ssleay_rand_add) chains all of 'md',
|
||||
* which makes it more suitable for this purpose.
|
||||
*/
|
||||
|
||||
int n = STATE_SIZE; /* so that the complete pool gets accessed */
|
||||
while (n > 0)
|
||||
{
|
||||
#if MD_DIGEST_LENGTH > 20
|
||||
# error "Please adjust DUMMY_SEED."
|
||||
#endif
|
||||
#define DUMMY_SEED "...................." /* at least MD_DIGEST_LENGTH */
|
||||
/* Note that the seed does not matter, it's just that
|
||||
* ssleay_rand_add expects to have something to hash. */
|
||||
ssleay_rand_add(DUMMY_SEED, MD_DIGEST_LENGTH, 0.0);
|
||||
n -= MD_DIGEST_LENGTH;
|
||||
}
|
||||
if (ok)
|
||||
stirred_pool = 1;
|
||||
}
|
||||
|
||||
st_idx=state_index;
|
||||
st_num=state_num;
|
||||
md_c[0] = md_count[0];
|
||||
md_c[1] = md_count[1];
|
||||
memcpy(local_md, md, sizeof md);
|
||||
|
||||
state_index+=num_ceil;
|
||||
if (state_index > state_num)
|
||||
state_index %= state_num;
|
||||
|
||||
/* state[st_idx], ..., state[(st_idx + num_ceil - 1) % st_num]
|
||||
* are now ours (but other threads may use them too) */
|
||||
|
||||
md_count[0] += 1;
|
||||
|
||||
/* before unlocking, we must clear 'crypto_lock_rand' */
|
||||
crypto_lock_rand = 0;
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
|
||||
|
||||
while (num > 0)
|
||||
{
|
||||
/* num_ceil -= MD_DIGEST_LENGTH/2 */
|
||||
j=(num >= MD_DIGEST_LENGTH/2)?MD_DIGEST_LENGTH/2:num;
|
||||
num-=j;
|
||||
MD_Init(&m);
|
||||
#ifndef GETPID_IS_MEANINGLESS
|
||||
if (curr_pid) /* just in the first iteration to save time */
|
||||
{
|
||||
MD_Update(&m,(unsigned char*)&curr_pid,sizeof curr_pid);
|
||||
curr_pid = 0;
|
||||
}
|
||||
#endif
|
||||
MD_Update(&m,local_md,MD_DIGEST_LENGTH);
|
||||
MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
|
||||
#ifndef PURIFY
|
||||
MD_Update(&m,buf,j); /* purify complains */
|
||||
#endif
|
||||
k=(st_idx+MD_DIGEST_LENGTH/2)-st_num;
|
||||
if (k > 0)
|
||||
{
|
||||
MD_Update(&m,&(state[st_idx]),MD_DIGEST_LENGTH/2-k);
|
||||
MD_Update(&m,&(state[0]),k);
|
||||
}
|
||||
else
|
||||
MD_Update(&m,&(state[st_idx]),MD_DIGEST_LENGTH/2);
|
||||
MD_Final(&m,local_md);
|
||||
|
||||
for (i=0; i<MD_DIGEST_LENGTH/2; i++)
|
||||
{
|
||||
state[st_idx++]^=local_md[i]; /* may compete with other threads */
|
||||
if (st_idx >= st_num)
|
||||
st_idx=0;
|
||||
if (i < j)
|
||||
*(buf++)=local_md[i+MD_DIGEST_LENGTH/2];
|
||||
}
|
||||
}
|
||||
|
||||
MD_Init(&m);
|
||||
MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
|
||||
MD_Update(&m,local_md,MD_DIGEST_LENGTH);
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_RAND);
|
||||
MD_Update(&m,md,MD_DIGEST_LENGTH);
|
||||
MD_Final(&m,md);
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
|
||||
|
||||
EVP_MD_CTX_cleanup(&m);
|
||||
if (ok)
|
||||
return(1);
|
||||
else
|
||||
{
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
RANDerr(RAND_F_SSLEAY_RAND_BYTES,RAND_R_PRNG_NOT_SEEDED);
|
||||
ERR_add_error_data(1, "You need to read the OpenSSL FAQ, "
|
||||
"http://www.openssl.org/support/faq.html");
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* pseudo-random bytes that are guaranteed to be unique but not
|
||||
unpredictable */
|
||||
static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
|
||||
{
|
||||
int ret;
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
unsigned long err;
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
ret = RAND_bytes(buf, num);
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
if (ret == 0)
|
||||
{
|
||||
err = ERR_peek_error();
|
||||
if (ERR_GET_LIB(err) == ERR_LIB_RAND &&
|
||||
ERR_GET_REASON(err) == RAND_R_PRNG_NOT_SEEDED)
|
||||
ERR_clear_error();
|
||||
}
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int ssleay_rand_status(void)
|
||||
{
|
||||
int ret;
|
||||
int do_not_lock;
|
||||
|
||||
/* check if we already have the lock
|
||||
* (could happen if a RAND_poll() implementation calls RAND_status()) */
|
||||
if (crypto_lock_rand)
|
||||
{
|
||||
CRYPTO_r_lock(CRYPTO_LOCK_RAND2);
|
||||
do_not_lock = (locking_thread == CRYPTO_thread_id());
|
||||
CRYPTO_r_unlock(CRYPTO_LOCK_RAND2);
|
||||
}
|
||||
else
|
||||
do_not_lock = 0;
|
||||
|
||||
if (!do_not_lock)
|
||||
{
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_RAND);
|
||||
|
||||
/* prevent ssleay_rand_bytes() from trying to obtain the lock again */
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_RAND2);
|
||||
locking_thread = CRYPTO_thread_id();
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_RAND2);
|
||||
crypto_lock_rand = 1;
|
||||
}
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
RAND_poll();
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
ret = entropy >= ENTROPY_NEEDED;
|
||||
|
||||
if (!do_not_lock)
|
||||
{
|
||||
/* before unlocking, we must clear 'crypto_lock_rand' */
|
||||
crypto_lock_rand = 0;
|
||||
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif //PRIVATE_RAND_ENGINE
|
176
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/rand/rand_lib.c
Executable file
176
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/rand/rand_lib.c
Executable file
@ -0,0 +1,176 @@
|
||||
/* crypto/rand/rand_lib.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/rand.h>
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
#include <openssl/engine.h>
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
/* non-NULL if default_RAND_meth is ENGINE-provided */
|
||||
static ENGINE *funct_ref =NULL;
|
||||
#endif
|
||||
static const RAND_METHOD *default_RAND_meth = NULL;
|
||||
|
||||
int RAND_set_rand_method(const RAND_METHOD *meth)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if(funct_ref)
|
||||
{
|
||||
ENGINE_finish(funct_ref);
|
||||
funct_ref = NULL;
|
||||
}
|
||||
#endif
|
||||
default_RAND_meth = meth;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const RAND_METHOD *RAND_get_rand_method(void)
|
||||
{
|
||||
if (!default_RAND_meth)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
ENGINE *e = ENGINE_get_default_RAND();
|
||||
if(e)
|
||||
{
|
||||
default_RAND_meth = ENGINE_get_RAND(e);
|
||||
if(!default_RAND_meth)
|
||||
{
|
||||
ENGINE_finish(e);
|
||||
e = NULL;
|
||||
}
|
||||
}
|
||||
if(e)
|
||||
funct_ref = e;
|
||||
else
|
||||
#endif
|
||||
default_RAND_meth = RAND_SSLeay();
|
||||
}
|
||||
return default_RAND_meth;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
int RAND_set_rand_engine(ENGINE *engine)
|
||||
{
|
||||
const RAND_METHOD *tmp_meth = NULL;
|
||||
if(engine)
|
||||
{
|
||||
if(!ENGINE_init(engine))
|
||||
return 0;
|
||||
tmp_meth = ENGINE_get_RAND(engine);
|
||||
if(!tmp_meth)
|
||||
{
|
||||
ENGINE_finish(engine);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* This function releases any prior ENGINE so call it first */
|
||||
RAND_set_rand_method(tmp_meth);
|
||||
funct_ref = engine;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
void RAND_cleanup(void)
|
||||
{
|
||||
const RAND_METHOD *meth = RAND_get_rand_method();
|
||||
if (meth && meth->cleanup)
|
||||
meth->cleanup();
|
||||
RAND_set_rand_method(NULL);
|
||||
}
|
||||
|
||||
void RAND_seed(const void *buf, int num)
|
||||
{
|
||||
const RAND_METHOD *meth = RAND_get_rand_method();
|
||||
if (meth && meth->seed)
|
||||
meth->seed(buf,num);
|
||||
}
|
||||
|
||||
void RAND_add(const void *buf, int num, int entropy)
|
||||
{
|
||||
const RAND_METHOD *meth = RAND_get_rand_method();
|
||||
if (meth && meth->add)
|
||||
meth->add(buf,num,entropy);
|
||||
}
|
||||
|
||||
int RAND_bytes(unsigned char *buf, int num)
|
||||
{
|
||||
const RAND_METHOD *meth = RAND_get_rand_method();
|
||||
if (meth && meth->bytes)
|
||||
return meth->bytes(buf,num);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int RAND_pseudo_bytes(unsigned char *buf, int num)
|
||||
{
|
||||
const RAND_METHOD *meth = RAND_get_rand_method();
|
||||
if (meth && meth->pseudorand)
|
||||
return meth->pseudorand(buf,num);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int RAND_status(void)
|
||||
{
|
||||
const RAND_METHOD *meth = RAND_get_rand_method();
|
||||
if (meth && meth->status)
|
||||
return meth->status();
|
||||
return 0;
|
||||
}
|
79
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/sha/sha1dgst.c
Executable file
79
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/sha/sha1dgst.c
Executable file
@ -0,0 +1,79 @@
|
||||
/* crypto/sha/sha1dgst.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the 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 acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* 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
|
||||
* 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 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.
|
||||
*
|
||||
* 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
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#include <openssl/opensslconf.h>
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
#if !defined(OPENSSL_NO_SHA1) && !defined(OPENSSL_NO_SHA)
|
||||
|
||||
#undef SHA_0
|
||||
#define SHA_1
|
||||
|
||||
#include <openssl/opensslv.h>
|
||||
|
||||
const char *SHA1_version="SHA1" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
/* The implementation is in ../md32_common.h */
|
||||
|
||||
#include "sha_locl.h"
|
||||
|
||||
#endif
|
||||
|
325
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/sha/sha256.c
Executable file
325
wlan/8192es/DriverSrcPkg/Users/wsc/portingssl/crypto/sha/sha256.c
Executable file
@ -0,0 +1,325 @@
|
||||
/* crypto/sha/sha256.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2004 The OpenSSL Project. All rights reserved
|
||||
* according to the OpenSSL license [found in ../../LICENSE].
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/*Begin: comment out , 17Aug2006, Chris */
|
||||
#if 0
|
||||
#include <openssl/opensslconf.h>
|
||||
#endif
|
||||
/*End: comment out , 17Aug2006, Chris */
|
||||
|
||||
#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA256)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/opensslv.h>
|
||||
|
||||
const char *SHA256_version="SHA-256" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
int SHA224_Init (SHA256_CTX *c)
|
||||
{
|
||||
c->h[0]=0xc1059ed8UL; c->h[1]=0x367cd507UL;
|
||||
c->h[2]=0x3070dd17UL; c->h[3]=0xf70e5939UL;
|
||||
c->h[4]=0xffc00b31UL; c->h[5]=0x68581511UL;
|
||||
c->h[6]=0x64f98fa7UL; c->h[7]=0xbefa4fa4UL;
|
||||
c->Nl=0; c->Nh=0;
|
||||
c->num=0; c->md_len=SHA224_DIGEST_LENGTH;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SHA256_Init (SHA256_CTX *c)
|
||||
{
|
||||
c->h[0]=0x6a09e667UL; c->h[1]=0xbb67ae85UL;
|
||||
c->h[2]=0x3c6ef372UL; c->h[3]=0xa54ff53aUL;
|
||||
c->h[4]=0x510e527fUL; c->h[5]=0x9b05688cUL;
|
||||
c->h[6]=0x1f83d9abUL; c->h[7]=0x5be0cd19UL;
|
||||
c->Nl=0; c->Nh=0;
|
||||
c->num=0; c->md_len=SHA256_DIGEST_LENGTH;
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md)
|
||||
{
|
||||
SHA256_CTX c;
|
||||
static unsigned char m[SHA224_DIGEST_LENGTH];
|
||||
|
||||
if (md == NULL) md=m;
|
||||
SHA224_Init(&c);
|
||||
SHA256_Update(&c,d,n);
|
||||
SHA256_Final(md,&c);
|
||||
OPENSSL_cleanse(&c,sizeof(c));
|
||||
return(md);
|
||||
}
|
||||
|
||||
unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md)
|
||||
{
|
||||
SHA256_CTX c;
|
||||
static unsigned char m[SHA256_DIGEST_LENGTH];
|
||||
|
||||
if (md == NULL) md=m;
|
||||
SHA256_Init(&c);
|
||||
SHA256_Update(&c,d,n);
|
||||
SHA256_Final(md,&c);
|
||||
OPENSSL_cleanse(&c,sizeof(c));
|
||||
return(md);
|
||||
}
|
||||
|
||||
int SHA224_Update(SHA256_CTX *c, const void *data, size_t len)
|
||||
{ return SHA256_Update (c,data,len); }
|
||||
int SHA224_Final (unsigned char *md, SHA256_CTX *c)
|
||||
{ return SHA256_Final (md,c); }
|
||||
|
||||
#ifndef SHA_LONG_LOG2
|
||||
#define SHA_LONG_LOG2 2 /* default to 32 bits */
|
||||
#endif
|
||||
|
||||
#define DATA_ORDER_IS_BIG_ENDIAN
|
||||
|
||||
#define HASH_LONG SHA_LONG
|
||||
#define HASH_LONG_LOG2 SHA_LONG_LOG2
|
||||
#define HASH_CTX SHA256_CTX
|
||||
#define HASH_CBLOCK SHA_CBLOCK
|
||||
#define HASH_LBLOCK SHA_LBLOCK
|
||||
/*
|
||||
* Note that FIPS180-2 discusses "Truncation of the Hash Function Output."
|
||||
* default: case below covers for it. It's not clear however if it's
|
||||
* permitted to truncate to amount of bytes not divisible by 4. I bet not,
|
||||
* but if it is, then default: case shall be extended. For reference.
|
||||
* Idea behind separate cases for pre-defined lenghts is to let the
|
||||
* compiler decide if it's appropriate to unroll small loops.
|
||||
*/
|
||||
#define HASH_MAKE_STRING(c,s) do { \
|
||||
unsigned long ll; \
|
||||
unsigned int n; \
|
||||
switch ((c)->md_len) \
|
||||
{ case SHA224_DIGEST_LENGTH: \
|
||||
for (n=0;n<SHA224_DIGEST_LENGTH/4;n++) \
|
||||
{ ll=(c)->h[n]; HOST_l2c(ll,(s)); } \
|
||||
break; \
|
||||
case SHA256_DIGEST_LENGTH: \
|
||||
for (n=0;n<SHA256_DIGEST_LENGTH/4;n++) \
|
||||
{ ll=(c)->h[n]; HOST_l2c(ll,(s)); } \
|
||||
break; \
|
||||
default: \
|
||||
if ((c)->md_len > SHA256_DIGEST_LENGTH) \
|
||||
return 0; \
|
||||
for (n=0;n<(c)->md_len/4;n++) \
|
||||
{ ll=(c)->h[n]; HOST_l2c(ll,(s)); } \
|
||||
break; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define HASH_UPDATE SHA256_Update
|
||||
#define HASH_TRANSFORM SHA256_Transform
|
||||
#define HASH_FINAL SHA256_Final
|
||||
#define HASH_BLOCK_HOST_ORDER sha256_block_host_order
|
||||
#define HASH_BLOCK_DATA_ORDER sha256_block_data_order
|
||||
void sha256_block_host_order (SHA256_CTX *ctx, const void *in, size_t num);
|
||||
void sha256_block_data_order (SHA256_CTX *ctx, const void *in, size_t num);
|
||||
|
||||
#include "md32_common.h"
|
||||
|
||||
#ifdef SHA256_ASM
|
||||
void sha256_block (SHA256_CTX *ctx, const void *in, size_t num, int host);
|
||||
#else
|
||||
static const SHA_LONG K256[64] = {
|
||||
0x428a2f98UL,0x71374491UL,0xb5c0fbcfUL,0xe9b5dba5UL,
|
||||
0x3956c25bUL,0x59f111f1UL,0x923f82a4UL,0xab1c5ed5UL,
|
||||
0xd807aa98UL,0x12835b01UL,0x243185beUL,0x550c7dc3UL,
|
||||
0x72be5d74UL,0x80deb1feUL,0x9bdc06a7UL,0xc19bf174UL,
|
||||
0xe49b69c1UL,0xefbe4786UL,0x0fc19dc6UL,0x240ca1ccUL,
|
||||
0x2de92c6fUL,0x4a7484aaUL,0x5cb0a9dcUL,0x76f988daUL,
|
||||
0x983e5152UL,0xa831c66dUL,0xb00327c8UL,0xbf597fc7UL,
|
||||
0xc6e00bf3UL,0xd5a79147UL,0x06ca6351UL,0x14292967UL,
|
||||
0x27b70a85UL,0x2e1b2138UL,0x4d2c6dfcUL,0x53380d13UL,
|
||||
0x650a7354UL,0x766a0abbUL,0x81c2c92eUL,0x92722c85UL,
|
||||
0xa2bfe8a1UL,0xa81a664bUL,0xc24b8b70UL,0xc76c51a3UL,
|
||||
0xd192e819UL,0xd6990624UL,0xf40e3585UL,0x106aa070UL,
|
||||
0x19a4c116UL,0x1e376c08UL,0x2748774cUL,0x34b0bcb5UL,
|
||||
0x391c0cb3UL,0x4ed8aa4aUL,0x5b9cca4fUL,0x682e6ff3UL,
|
||||
0x748f82eeUL,0x78a5636fUL,0x84c87814UL,0x8cc70208UL,
|
||||
0x90befffaUL,0xa4506cebUL,0xbef9a3f7UL,0xc67178f2UL };
|
||||
|
||||
/*
|
||||
* FIPS specification refers to right rotations, while our ROTATE macro
|
||||
* is left one. This is why you might notice that rotation coefficients
|
||||
* differ from those observed in FIPS document by 32-N...
|
||||
*/
|
||||
#define Sigma0(x) (ROTATE((x),30) ^ ROTATE((x),19) ^ ROTATE((x),10))
|
||||
#define Sigma1(x) (ROTATE((x),26) ^ ROTATE((x),21) ^ ROTATE((x),7))
|
||||
#define sigma0(x) (ROTATE((x),25) ^ ROTATE((x),14) ^ ((x)>>3))
|
||||
#define sigma1(x) (ROTATE((x),15) ^ ROTATE((x),13) ^ ((x)>>10))
|
||||
|
||||
#define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z)))
|
||||
#define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
|
||||
|
||||
#ifdef OPENSSL_SMALL_FOOTPRINT
|
||||
|
||||
static void sha256_block (SHA256_CTX *ctx, const void *in, size_t num, int host)
|
||||
{
|
||||
unsigned MD32_REG_T a,b,c,d,e,f,g,h,s0,s1,T1,T2;
|
||||
SHA_LONG X[16];
|
||||
int i;
|
||||
const unsigned char *data=in;
|
||||
|
||||
while (num--) {
|
||||
|
||||
a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3];
|
||||
e = ctx->h[4]; f = ctx->h[5]; g = ctx->h[6]; h = ctx->h[7];
|
||||
|
||||
if (host)
|
||||
{
|
||||
const SHA_LONG *W=(const SHA_LONG *)data;
|
||||
|
||||
for (i=0;i<16;i++)
|
||||
{
|
||||
T1 = X[i] = W[i];
|
||||
T1 += h + Sigma1(e) + Ch(e,f,g) + K256[i];
|
||||
T2 = Sigma0(a) + Maj(a,b,c);
|
||||
h = g; g = f; f = e; e = d + T1;
|
||||
d = c; c = b; b = a; a = T1 + T2;
|
||||
}
|
||||
|
||||
data += SHA256_CBLOCK;
|
||||
}
|
||||
else
|
||||
{
|
||||
SHA_LONG l;
|
||||
|
||||
for (i=0;i<16;i++)
|
||||
{
|
||||
HOST_c2l(data,l); T1 = X[i] = l;
|
||||
T1 += h + Sigma1(e) + Ch(e,f,g) + K256[i];
|
||||
T2 = Sigma0(a) + Maj(a,b,c);
|
||||
h = g; g = f; f = e; e = d + T1;
|
||||
d = c; c = b; b = a; a = T1 + T2;
|
||||
}
|
||||
}
|
||||
|
||||
for (;i<64;i++)
|
||||
{
|
||||
s0 = X[(i+1)&0x0f]; s0 = sigma0(s0);
|
||||
s1 = X[(i+14)&0x0f]; s1 = sigma1(s1);
|
||||
|
||||
T1 = X[i&0xf] += s0 + s1 + X[(i+9)&0xf];
|
||||
T1 += h + Sigma1(e) + Ch(e,f,g) + K256[i];
|
||||
T2 = Sigma0(a) + Maj(a,b,c);
|
||||
h = g; g = f; f = e; e = d + T1;
|
||||
d = c; c = b; b = a; a = T1 + T2;
|
||||
}
|
||||
|
||||
ctx->h[0] += a; ctx->h[1] += b; ctx->h[2] += c; ctx->h[3] += d;
|
||||
ctx->h[4] += e; ctx->h[5] += f; ctx->h[6] += g; ctx->h[7] += h;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define ROUND_00_15(i,a,b,c,d,e,f,g,h) do { \
|
||||
T1 += h + Sigma1(e) + Ch(e,f,g) + K256[i]; \
|
||||
h = Sigma0(a) + Maj(a,b,c); \
|
||||
d += T1; h += T1; } while (0)
|
||||
|
||||
#define ROUND_16_63(i,a,b,c,d,e,f,g,h,X) do { \
|
||||
s0 = X[(i+1)&0x0f]; s0 = sigma0(s0); \
|
||||
s1 = X[(i+14)&0x0f]; s1 = sigma1(s1); \
|
||||
T1 = X[(i)&0x0f] += s0 + s1 + X[(i+9)&0x0f]; \
|
||||
ROUND_00_15(i,a,b,c,d,e,f,g,h); } while (0)
|
||||
|
||||
static void sha256_block (SHA256_CTX *ctx, const void *in, size_t num, int host)
|
||||
{
|
||||
unsigned MD32_REG_T a,b,c,d,e,f,g,h,s0,s1,T1;
|
||||
SHA_LONG X[16];
|
||||
int i;
|
||||
const unsigned char *data=in;
|
||||
|
||||
while (num--) {
|
||||
|
||||
a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3];
|
||||
e = ctx->h[4]; f = ctx->h[5]; g = ctx->h[6]; h = ctx->h[7];
|
||||
|
||||
if (host)
|
||||
{
|
||||
const SHA_LONG *W=(const SHA_LONG *)data;
|
||||
|
||||
T1 = X[0] = W[0]; ROUND_00_15(0,a,b,c,d,e,f,g,h);
|
||||
T1 = X[1] = W[1]; ROUND_00_15(1,h,a,b,c,d,e,f,g);
|
||||
T1 = X[2] = W[2]; ROUND_00_15(2,g,h,a,b,c,d,e,f);
|
||||
T1 = X[3] = W[3]; ROUND_00_15(3,f,g,h,a,b,c,d,e);
|
||||
T1 = X[4] = W[4]; ROUND_00_15(4,e,f,g,h,a,b,c,d);
|
||||
T1 = X[5] = W[5]; ROUND_00_15(5,d,e,f,g,h,a,b,c);
|
||||
T1 = X[6] = W[6]; ROUND_00_15(6,c,d,e,f,g,h,a,b);
|
||||
T1 = X[7] = W[7]; ROUND_00_15(7,b,c,d,e,f,g,h,a);
|
||||
T1 = X[8] = W[8]; ROUND_00_15(8,a,b,c,d,e,f,g,h);
|
||||
T1 = X[9] = W[9]; ROUND_00_15(9,h,a,b,c,d,e,f,g);
|
||||
T1 = X[10] = W[10]; ROUND_00_15(10,g,h,a,b,c,d,e,f);
|
||||
T1 = X[11] = W[11]; ROUND_00_15(11,f,g,h,a,b,c,d,e);
|
||||
T1 = X[12] = W[12]; ROUND_00_15(12,e,f,g,h,a,b,c,d);
|
||||
T1 = X[13] = W[13]; ROUND_00_15(13,d,e,f,g,h,a,b,c);
|
||||
T1 = X[14] = W[14]; ROUND_00_15(14,c,d,e,f,g,h,a,b);
|
||||
T1 = X[15] = W[15]; ROUND_00_15(15,b,c,d,e,f,g,h,a);
|
||||
|
||||
data += SHA256_CBLOCK;
|
||||
}
|
||||
else
|
||||
{
|
||||
SHA_LONG l;
|
||||
|
||||
HOST_c2l(data,l); T1 = X[0] = l; ROUND_00_15(0,a,b,c,d,e,f,g,h);
|
||||
HOST_c2l(data,l); T1 = X[1] = l; ROUND_00_15(1,h,a,b,c,d,e,f,g);
|
||||
HOST_c2l(data,l); T1 = X[2] = l; ROUND_00_15(2,g,h,a,b,c,d,e,f);
|
||||
HOST_c2l(data,l); T1 = X[3] = l; ROUND_00_15(3,f,g,h,a,b,c,d,e);
|
||||
HOST_c2l(data,l); T1 = X[4] = l; ROUND_00_15(4,e,f,g,h,a,b,c,d);
|
||||
HOST_c2l(data,l); T1 = X[5] = l; ROUND_00_15(5,d,e,f,g,h,a,b,c);
|
||||
HOST_c2l(data,l); T1 = X[6] = l; ROUND_00_15(6,c,d,e,f,g,h,a,b);
|
||||
HOST_c2l(data,l); T1 = X[7] = l; ROUND_00_15(7,b,c,d,e,f,g,h,a);
|
||||
HOST_c2l(data,l); T1 = X[8] = l; ROUND_00_15(8,a,b,c,d,e,f,g,h);
|
||||
HOST_c2l(data,l); T1 = X[9] = l; ROUND_00_15(9,h,a,b,c,d,e,f,g);
|
||||
HOST_c2l(data,l); T1 = X[10] = l; ROUND_00_15(10,g,h,a,b,c,d,e,f);
|
||||
HOST_c2l(data,l); T1 = X[11] = l; ROUND_00_15(11,f,g,h,a,b,c,d,e);
|
||||
HOST_c2l(data,l); T1 = X[12] = l; ROUND_00_15(12,e,f,g,h,a,b,c,d);
|
||||
HOST_c2l(data,l); T1 = X[13] = l; ROUND_00_15(13,d,e,f,g,h,a,b,c);
|
||||
HOST_c2l(data,l); T1 = X[14] = l; ROUND_00_15(14,c,d,e,f,g,h,a,b);
|
||||
HOST_c2l(data,l); T1 = X[15] = l; ROUND_00_15(15,b,c,d,e,f,g,h,a);
|
||||
}
|
||||
|
||||
for (i=16;i<64;i+=8)
|
||||
{
|
||||
ROUND_16_63(i+0,a,b,c,d,e,f,g,h,X);
|
||||
ROUND_16_63(i+1,h,a,b,c,d,e,f,g,X);
|
||||
ROUND_16_63(i+2,g,h,a,b,c,d,e,f,X);
|
||||
ROUND_16_63(i+3,f,g,h,a,b,c,d,e,X);
|
||||
ROUND_16_63(i+4,e,f,g,h,a,b,c,d,X);
|
||||
ROUND_16_63(i+5,d,e,f,g,h,a,b,c,X);
|
||||
ROUND_16_63(i+6,c,d,e,f,g,h,a,b,X);
|
||||
ROUND_16_63(i+7,b,c,d,e,f,g,h,a,X);
|
||||
}
|
||||
|
||||
ctx->h[0] += a; ctx->h[1] += b; ctx->h[2] += c; ctx->h[3] += d;
|
||||
ctx->h[4] += e; ctx->h[5] += f; ctx->h[6] += g; ctx->h[7] += h;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* SHA256_ASM */
|
||||
|
||||
/*
|
||||
* Idea is to trade couple of cycles for some space. On IA-32 we save
|
||||
* about 4K in "big footprint" case. In "small footprint" case any gain
|
||||
* is appreciated:-)
|
||||
*/
|
||||
void HASH_BLOCK_HOST_ORDER (SHA256_CTX *ctx, const void *in, size_t num)
|
||||
{ sha256_block (ctx,in,num,1); }
|
||||
|
||||
void HASH_BLOCK_DATA_ORDER (SHA256_CTX *ctx, const void *in, size_t num)
|
||||
{ sha256_block (ctx,in,num,0); }
|
||||
|
||||
#endif /* OPENSSL_NO_SHA256 */
|
Reference in New Issue
Block a user