📄 icl.h
字号:
/*
Copyright (c) 1999 - 2002 Intel Corporation. All rights reserved
This software and associated documentation (if any) is furnished
under a license and may only be used or copied in accordance
with the terms of the license. Except as permitted by such
license, no part of this software or documentation may be
reproduced, stored in a retrieval system, or transmitted in any
form or by any means without the express written consent of
Intel Corporation.
*/
/*
* WARNING: EXPORT RESTRICTED.
* This software is subject to the U.S. Export Administration Regulations
* and other U.S. law, and may not be exported or re-exported to certain
* countries (currently Afghanistan (Taliban-controlled areas), Cuba, Iran,
* Iraq, Libya, North Korea, Serbia (except Kosovo), Sudan and Syria) or to
* persons or entities prohibited from receiving U.S. exports (including Denied
* Parties, Specially Designated Nationals, and entities on the Bureau of
* Export Administration Entity List or involved with missile technology or
* nuclear, chemical or biological weapons).
*/
/*
* INTEL CONFIDENTIAL
* This file, software, or program is supplied under the terms
* of a licence agreement or nondisclosure agreement with
* Intel Corporation and may not be copied or disclosed except
* in accordance with the terms of that agreement. This file,
* software, or program contains copyrighted material and/or
* trade secret information of Intel Corporation, and must be
* treated as such. Intel reserves all rights in this material,
* except as the licence agreement or nondisclosure agreement
* specifically indicate.
*/
/*
Module name: icl.h
Intel Cryptographic Library, Version v1.0
This Intel Cryptographic Library contains:
* 1024 bit RSA Encryption and Decryption
* 1024 bit RSA Key Generation
* MD5 Message Digest Algorithm
* SHA Message Digest Algorithm
* Data Encryption Standard in ECB/CBC mode
* Password Based Encryption
* Random Number Generator
* RC4 with variable key length
* RC5 16/32/64 with variable #rounds, variable key length in ECB/CBC modes
*/
#ifndef _ICL_INCLUDE_
#define _ICL_INCLUDE_
#define WORDSIZE 32
#define MODULUSBITS 1024
#define MODULUS (MODULUSBITS / WORDSIZE)
#define MODULUSBYTES (MODULUSBITS / 8)
/* Maximum number of characters processed in the passphrase of PBE */
#define MAXPASSPHRASELENGTH 32
/* Method identifier for PBE */
enum {PBE_MD5DES=1, PBE_MD5IDEA, PBE_SHADES, PBE_SHAIDEA};
enum {ICL_PAD_NONE =0,
ICL_PAD_CUSTOM =ICL_PAD_NONE+1,
ICL_PAD_ZERO =ICL_PAD_NONE+2,
ICL_PAD_ONE =ICL_PAD_NONE+3,
ICL_PAD_ALTERNATE =ICL_PAD_NONE+4,
ICL_PAD_FF =ICL_PAD_NONE+5,
ICL_PAD_PKCS7 =ICL_PAD_NONE+6,
ICL_PAD_STEALING =ICL_PAD_NONE+7};
/***************************************************************/
/* Intel Cryptographic Library Supported Algorithms */
/***************************************************************/
#ifdef _RSA
#define ICL_RSA
#endif
#ifdef _MD2
#define ICL_MD2
#endif
#define ICL_DSA
//#define ICL_MD5
#define ICL_SHA1
#define ICL_DES
//#define ICL_DESRandom
//#define ICL_RC4
//#define ICL_RC5
/*-------- The following are the algorithm dependence of ICL library --------*/
/* There are two random number generators implemented (SHA1 & DES) for ICL_DSSSign.*/
#ifdef ICL_DSA
#ifndef ICL_SHA1
#define ICL_SHA1
#endif
#endif
/* ICl_RandGen is composed of a state machine and a DES core.*/
/*
#ifdef ICL_DESRandom
#ifndef ICL_DES
#define ICL_DES
#endif
#endif
*/
/***************************************************************/
/* Intel Cryptographic Library Data Types */
/***************************************************************/
/* */
/* Multi-precision integers are stored the least significant */
/* byte first. This ensures that Intel 80x86 processors access */
/* the same data as bytes, words, dwords, or qwords without */
/* reordering. The least significant byte of each integer is */
/* stored in "value[0]" of "ICLData" type. */
/***************************************************************/
/* One byte (8 bit) for ICL data types */
typedef unsigned char ICLByte;
/* One word for ICL data types */
typedef unsigned long ICLWord;
/* DES Key , 64 bit with low order byte first */
typedef ICLByte ICLDESKey[8];
/* DES Initial Value, 64 bit with low order byte first */
typedef ICLByte ICLDESIV[8];
/* RC5 Initial Value, 32,64,128 bits with low order byte first */
typedef ICLByte ICLRC5IV[16];
/* MD5 digested data, 128 bit with low order byte first */
typedef ICLByte ICLMD5Digest[16];
/* MD2 digested data, 128 bit with low order byte first */
#define ICLMD2_DIGEST_LENGTH 16
#define ICLMD2_ENC_BLOCK_LENGTH (3 * ICLMD2_DIGEST_LENGTH)
typedef ICLByte ICLMD2Digest[ICLMD2_DIGEST_LENGTH];
/* SHA digested data, 160 bit with low order byte first */
typedef ICLByte ICLSHADigest[20];
/* The salt type used in Password Based Encryption */
typedef ICLWord ICLSalt[2];
/* The null terminated password string in PBE */
typedef ICLByte *ICLPassPhrase;
/***************************************************************/
/* ICLData has any number of ICLWords, not pre-allocated. */
/* Space must be reserved by the user. */
/***************************************************************/
typedef struct {
long length; /* number of bytes in 'value' */
ICLByte *value; /* memory address of the array */
} ICLData;
/*-------------------------*/
#ifdef ICL_RSA
/* RSA Public Key structure */
typedef struct {
ICLData PublicExponent; /* e */
ICLData Modulus; /* n */
} ICLRSAPublicKey;
/* RSA Private Key Structure */
typedef struct {
ICLData PublicExponent; /* e */
ICLData PrivateExponent; /* d */
ICLData Modulus; /* n */
ICLData Prime[2]; /* p, q */
ICLData PrimeExponent[2]; /* d mod (p-1), d mod (q-1) */
ICLData Coefficient; /* coeff = q^{-1} mod p */
} ICLRSAPrivateKey;
#endif
/*-------------------------*/
#ifdef ICL_RC4
/* RC4 Key structure */
typedef struct {
long length;
ICLByte *value;
} ICLRC4Key;
/* RC4 State structure */
typedef struct {
ICLByte state[256]; /* RC4 state */
ICLByte i, j;
} ICLRC4State;
#endif
/*-------------------------*/
#ifdef ICL_RC5
/* RC5 Key structure */
typedef struct {
long length;
ICLByte *value;
} ICLRC5Key;
/* RC5 State Structure */
typedef struct {
ICLWord regsize; /* register size (16,32,64) */
ICLWord rounds; /* # of rounds (0..255) */
ICLWord keysize; /* # of bytes in key (0..255) */
ICLWord iv[4]; /* holds CBC vector */
ICLWord keytable[1024]; /* holds expanded key table */
ICLWord mode; /* tracks ECB, CBC, PAD modes */
ICLByte buffer[32]; /* holds partial data chunks */
ICLWord buflen; /* length of buffer[] */
ICLWord BLKS; /* block length in bytes */
ICLWord LOG2; /* log2(BLKS) */
} ICLRC5State;
#endif
/*-------------------------*/
#ifdef ICL_MD2
/* MD2 State structure */
typedef struct _icl_md2state {
ICLByte EncBlock[ICLMD2_ENC_BLOCK_LENGTH];
ICLByte InBuffer[ICLMD2_DIGEST_LENGTH];
ICLByte CheckSum[ICLMD2_DIGEST_LENGTH];
ICLWord Index;
} ICLMD2State;
#endif
/*-------------------------*/
#ifdef ICL_MD5
/* MD5 State Structure */
typedef struct {
ICLWord state[4]; /* MD5 State */
ICLWord count[2]; /* length of Message in bits */
ICLByte buffer[64]; /* temprorary buffer */
} ICLMD5State;
#endif
/*-------------------------*/
#ifdef ICL_SHA1
/* SHA State Structure */
typedef struct {
ICLWord state[5]; /* SHA State */
ICLWord count[2]; /* length of Message in bits */
ICLByte buffer[64]; /* temprorary buffer */
} ICLSHAState;
#endif
/*-------------------------*/
#ifdef ICL_DES
/* DES State Structure */
typedef struct {
ICLWord roundkey[32]; /* holds expanded key table */
ICLByte vector[8]; /* holds CBC vector */
ICLByte buffer[16]; /* holds partial 8-byte chunks */
ICLWord buflen; /* length of buffer[] */
ICLWord mode; /* internal use (e=1,d=2) */
} ICLDESState;
#endif
/*-------------------------*/
#ifdef ICL_DSA
/* DSS Public Key Structure */
typedef struct {
ICLData PrimeModulus; /* p */
ICLData PrimeDivisor; /* q */
ICLData OrderQ; /* g */
ICLData PublicKey; /* y */
} ICLDSSPublicKey;
/* DSS Private Key Structure */
typedef struct {
ICLData PrimeModulus; /* p */
ICLData PrimeDivisor; /* q */
ICLData OrderQ; /* g */
ICLData PrivateKey; /* x */
} ICLDSSPrivateKey;
#endif
/*-------------------------*/
/***************************************************************/
/* Function Prototypes */
/***************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef ICL_DES
int ICL_DESBeginECB
(ICLDESKey DESkey,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -