Nebula
Nebula
|
类 | |
struct | rc5UserKey |
Definition of RC5 user key object. 更多... | |
struct | rc5CBCAlg |
Definition of the RC5 CBC algorithm object. 更多... | |
宏定义 | |
#define | RC5_FIRST_VERSION 1 |
#define | RC5_WORD unsigned int |
#define | W (32) |
#define | WW (W / 8) |
#define | ROT_MASK (W - 1) |
#define | BB ((2 * W) / 8) /* Bytes per block */ |
#define | SHL(x, s) ((RC5_WORD)((x)<<((s)&ROT_MASK))) |
#define | SHR(x, s, w) ((RC5_WORD)((x)>>((w)-((s)&ROT_MASK)))) |
#define | ROTL(x, s, w) ((RC5_WORD)(SHL((x),(s))|SHR((x),(s),(w)))) |
#define | SHL1(x, s, w) ((RC5_WORD)((x)<<((w)-((s)&ROT_MASK)))) |
#define | SHR1(x, s) ((RC5_WORD)((x)>>((s)&ROT_MASK))) |
#define | ROTR(x, s, w) ((RC5_WORD)(SHR1((x),(s))|SHL1((x),(s),(w)))) |
#define | P16 0xb7e1 |
#define | Q16 0x9e37 |
#define | P32 0xb7e15163 |
#define | Q32 0x9e3779b9 |
#define | P64 0xb7e151628aed2a6b |
#define | Q64 0x9e3779b97f4a7c15 |
#define | Pw P32 /* Select 32 bit word size */ |
#define | Qw Q32 |
类型定义 | |
typedef struct rc5UserKey | rc5UserKey |
Definition of RC5 user key object. 更多... | |
typedef struct rc5CBCAlg | rc5CBCAlg |
Definition of the RC5 CBC algorithm object. 更多... | |
函数 | |
rc5UserKey * | RC5_Key_Create () |
Allocate and initialize an RC5 user key. 更多... | |
void | RC5_Key_Destroy (rc5UserKey *pKey) |
Zero and free an RC5 user key. 更多... | |
int | RC5_Key_Set (rc5UserKey *pKey, int keyLength, unsigned char *keyBytes) |
Set the value of an RC5 user key. 更多... | |
void | RC5_Key_Expand (int b, unsigned char *K, int R, RC5_WORD *S) |
Expand an RC5 user key. 更多... | |
void | RC5_Block_Encrypt (RC5_WORD *S, int R, unsigned char *in, unsigned char *out) |
encryption of a single input block 更多... | |
void | RC5_Block_Decrypt (RC5_WORD *S, int R, unsigned char *in, unsigned char *out) |
rc5CBCAlg * | RC5_CBC_Create (int Pad, int R, int Version, int bb, unsigned char *I) |
Allocate and initialize the RC5 CBC algorithm object. 更多... | |
void | RC5_CBC_Destroy (rc5CBCAlg *pAlg) |
Zero and free an RC5 algorithm object. 更多... | |
int | RC5_CBC_SetIV (rc5CBCAlg *pAlg, unsigned char *I) |
Setup a new initialization vector for a CBC operation and reset the CBC object. 更多... | |
int | RC5_CBC_Encrypt_Init (rc5CBCAlg *pAlg, rc5UserKey *pKey) |
Binding a key to a cipher object. 更多... | |
int | RC5_CBC_Encrypt_Update (rc5CBCAlg *pAlg, int N, unsigned char *P, int *pCipherLen, int maxCipherLen, unsigned char *C) |
Encrypt a buffer of plaintext. 更多... | |
int | RC5_CBC_Encrypt_Final (rc5CBCAlg *pAlg, int *pCipherLen, int maxCipherLen, unsigned char *C) |
Produce the final block of ciphertext including any padding, and then reset the algorithm object. 更多... | |
int | RC5_CBC_Decrypt_Init (rc5CBCAlg *pAlg, rc5UserKey *pKey) |
int | RC5_CBC_Decrypt_Update (rc5CBCAlg *pAlg, int N, unsigned char *C, int *plainLen, unsigned char *P) |
#define BB ((2 * W) / 8) /* Bytes per block */ |
#define P16 0xb7e1 |
Two constants, Pw and Qw, are defined for any word size W by the expressions: Pw=Odd((e-2)*2**W) Qw=Odd((phi-1)*2**W) e是自然对数的底(2.71828...),phi是黄金比例(1.61803...),2**W是2的W 此方,Odd(x)等于x如果x是奇数或等于x+1如果x是偶数。W等于16,32和64,Pw和 where e is the base of the natural logarithm (2.71828 ...), and phi is the golden ratio (1.61803 ...), and 2**W is 2 raised to the power of W, and Odd(x) is equal to x if x is odd, or equal to x plus one if x is even. For W equal to 16, 32, and 64, the Pw and Qw constants are the following hexadecimal values:
#define P32 0xb7e15163 |
#define P64 0xb7e151628aed2a6b |
#define Pw P32 /* Select 32 bit word size */ |
#define Q16 0x9e37 |
#define Q32 0x9e3779b9 |
#define Q64 0x9e3779b97f4a7c15 |
#define Qw Q32 |
#define RC5_FIRST_VERSION 1 |
#define RC5_WORD unsigned int |
#define ROT_MASK (W - 1) |
#define W (32) |
#define WW (W / 8) |
Definition of the RC5 CBC algorithm object.
typedef struct rc5UserKey rc5UserKey |
Definition of RC5 user key object.
void RC5_Block_Decrypt | ( | RC5_WORD * | S, |
int | R, | ||
unsigned char * | in, | ||
unsigned char * | out | ||
) |
void RC5_Block_Encrypt | ( | RC5_WORD * | S, |
int | R, | ||
unsigned char * | in, | ||
unsigned char * | out | ||
) |
encryption of a single input block
S | |
R | |
in | |
out |
rc5CBCAlg* RC5_CBC_Create | ( | int | Pad, |
int | R, | ||
int | Version, | ||
int | bb, | ||
unsigned char * | I | ||
) |
Allocate and initialize the RC5 CBC algorithm object.
Pad | 1 = RC5-CBC-Pad, 0 = RC5-CBC. |
R | Number of rounds. |
Version | RC5 version number. |
bb | Bytes per RC5 block == IV len. |
I | CBC IV, bb bytes long. |
int RC5_CBC_Decrypt_Init | ( | rc5CBCAlg * | pAlg, |
rc5UserKey * | pKey | ||
) |
int RC5_CBC_Decrypt_Update | ( | rc5CBCAlg * | pAlg, |
int | N, | ||
unsigned char * | C, | ||
int * | plainLen, | ||
unsigned char * | P | ||
) |
void RC5_CBC_Destroy | ( | rc5CBCAlg * | pAlg | ) |
Zero and free an RC5 algorithm object.
pAlg | RC5 CBC algorithm object |
int RC5_CBC_Encrypt_Final | ( | rc5CBCAlg * | pAlg, |
int * | pCipherLen, | ||
int | maxCipherLen, | ||
unsigned char * | C | ||
) |
Produce the final block of ciphertext including any padding, and then reset the algorithm object.
pAlg | Cipher algorithm object. |
pCipherLen | Gets byte len of C. |
maxCipherLen | Len of C buffer. |
C | Ciphertext buffer. |
int RC5_CBC_Encrypt_Init | ( | rc5CBCAlg * | pAlg, |
rc5UserKey * | pKey | ||
) |
Binding a key to a cipher object.
pAlg | RC5 CBC algorithm object |
pKey | user key |
int RC5_CBC_Encrypt_Update | ( | rc5CBCAlg * | pAlg, |
int | N, | ||
unsigned char * | P, | ||
int * | pCipherLen, | ||
int | maxCipherLen, | ||
unsigned char * | C | ||
) |
Encrypt a buffer of plaintext.
pAlg | Cipher algorithm object. |
N | Byte length of P. |
P | Plaintext buffer. |
pCipherLen | Gets byte len of C. |
maxCipherLen | Size of C. |
C | Ciphertext buffer. |
int RC5_CBC_SetIV | ( | rc5CBCAlg * | pAlg, |
unsigned char * | I | ||
) |
Setup a new initialization vector for a CBC operation and reset the CBC object.
pAlg | RC5 CBC algorithm object |
I | CBC Initialization vector, BB bytes. |
rc5UserKey* RC5_Key_Create | ( | ) |
Allocate and initialize an RC5 user key.
void RC5_Key_Destroy | ( | rc5UserKey * | pKey | ) |
Zero and free an RC5 user key.
pKey | user key |
void RC5_Key_Expand | ( | int | b, |
unsigned char * | K, | ||
int | R, | ||
RC5_WORD * | S | ||
) |
Expand an RC5 user key.
b | Byte length of secret key |
K | Secret key |
R | Number of rounds |
S | Expanded key buffer, 2*(R+1) words |
int RC5_Key_Set | ( | rc5UserKey * | pKey, |
int | keyLength, | ||
unsigned char * | keyBytes | ||
) |
Set the value of an RC5 user key.
pKey | user key |
keyLength | user key length |
keyBytes | user key bytes |