📄 fips186.h
字号:
/* Copyright 2003-2006, Voltage Security, all rights reserved.
*/
#include "vibecrypto.h"
#include "environment.h"
#include "base.h"
#include "libctx.h"
#include "algobj.h"
#include "random.h"
#include "mpint.h"
#ifndef _FIPS_186_2_PRNG_H
#define _FIPS_186_2_PRNG_H
#ifdef __cplusplus
extern "C" {
#endif
/* Implements VSeedRandom.
*/
int VOLT_CALLING_CONV FIPS186SeedRandom VOLT_PROTO_LIST ((
VoltRandomObject *obj,
unsigned char *seedData,
unsigned int seedLen
));
/* Implements VGenerateRandomBytes.
*/
int VOLT_CALLING_CONV FIPS186GenerateRandomBytes VOLT_PROTO_LIST ((
VoltRandomObject *obj,
unsigned char *randomBytes,
unsigned int randomLen
));
/* What are the allowed XKEY sizes? These are the amounts the app can
* pass in to avoid the INVALID_SET_INFO error.
*/
#define FIPS_186_PRNG_MIN_XKEY_SIZE 32
#define FIPS_186_PRNG_MAX_XKEY_SIZE 32
/* What is the sufficient seed length? This is the amount the app needs
* to pass in to avoid the INSUFFICIENT_SEED error.
*/
#define FIPS_186_PRNG_MIN_SEED_LEN 32
/* How big is the buffer that holds output bytes? This buffer will be
* the place where the bytes produced are first stored. Then as many
* as necessary will go to the output buffer. The number produced may
* be more than needed, so the rest will stick around in case another
* call to Generate is made.
*/
#define FIPS_186_PRNG_OUTPUT_BLOCK_SIZE 20
/* Use these values to determine what to compare and what to output.
*/
#define VOLT_FIPS_186_INIT 0
#define VOLT_FIPS_186_NO_BUFFER 1
#define VOLT_FIPS_186_PREVIOUS_BUFFER 2
#define VOLT_FIPS_186_CURRENT_BUFFER 3
/* The localCtx for FIPS 186 PRNG looks like this.
*/
typedef struct
{
unsigned int variation;
unsigned int blockSizeBits;
unsigned int byteSize;
VoltMpIntCtx *mpCtx;
VoltMpInt *primeQ;
VoltMpInt *base;
VoltMpInt *reduction;
unsigned char *xseed;
unsigned char *xkey;
unsigned char *seedBuffer;
unsigned int seedLen;
unsigned int seedCount;
VtAlgorithmObject digestObj;
unsigned int currentBytesLen;
unsigned int currentBytesOffset;
unsigned int previousBytesFlag;
unsigned char currentBytes[2 * FIPS_186_PRNG_OUTPUT_BLOCK_SIZE];
unsigned char previousBytes[2 * FIPS_186_PRNG_OUTPUT_BLOCK_SIZE];
} VoltFips186PrngCtx;
/* Implements VCtxDestroy.
*/
void VOLT_CALLING_CONV FIPS186CtxDestroy VOLT_PROTO_LIST ((
Pointer obj,
Pointer ctx
));
#ifdef __cplusplus
}
#endif
#endif /* _FIPS_186_2_PRNG_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -