#ifndef _CORECRYPTO_CCDRBG_H_
#define _CORECRYPTO_CCDRBG_H_
#include <corecrypto/cc.h>
#include <corecrypto/ccdrbg_impl.h>
#define CCDRBG_STATUS_OK 0
#define CCDRBG_STATUS_ERROR (-1)
#define CCDRBG_STATUS_NEED_RESEED (-2)
#define CCDRBG_STATUS_PARAM_ERROR (-3)
CC_INLINE size_t ccdrbg_context_size(const struct ccdrbg_info *drbg)
{
return drbg->size;
}
CC_INLINE int ccdrbg_init(const struct ccdrbg_info *info,
struct ccdrbg_state *drbg,
unsigned long entropyLength, const void* entropy,
unsigned long nonceLength, const void* nonce,
unsigned long psLength, const void* ps)
{
return info->init(info, drbg, entropyLength, entropy, nonceLength, nonce, psLength, ps);
}
CC_INLINE int ccdrbg_reseed(const struct ccdrbg_info *info,
struct ccdrbg_state *prng,
unsigned long entropylen, const void *entropy,
unsigned long inlen, const void *in)
{
return info->reseed(prng, entropylen, entropy, inlen, in);
}
CC_INLINE int ccdrbg_generate(const struct ccdrbg_info *info,
struct ccdrbg_state *prng,
unsigned long outlen, void *out,
unsigned long inlen, const void *in)
{
return info->generate(prng, outlen, out, inlen, in);
}
CC_INLINE void ccdrbg_done(const struct ccdrbg_info *info,
struct ccdrbg_state *prng)
{
info->done(prng);
}
extern struct ccdrbg_info ccdrbg_dummy_info;
extern struct ccdrbg_info ccdrbg_fipssha1_info;
struct ccdrbg_nistctr_custom {
const struct ccmode_ecb *ecb;
unsigned long keylen;
int strictFIPS;
int use_df;
};
void ccdrbg_factory_nistctr(struct ccdrbg_info *info, const struct ccdrbg_nistctr_custom *custom);
extern struct ccdrbg_info ccdrbg_nistdigest_info;
struct ccdrbg_nisthmac_custom {
const struct ccdigest_info *di;
int strictFIPS;
};
int ccdbrg_nisthmac_security_strength(const struct ccdrbg_nisthmac_custom *custom);
void ccdrbg_factory_nisthmac(struct ccdrbg_info *info, const struct ccdrbg_nisthmac_custom *custom);
#endif