|
|
|
@ -5,6 +5,25 @@
|
|
|
|
|
|
|
|
|
|
#include "capi-bridge.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace bridge _export(internal)
|
|
|
|
|
{
|
|
|
|
|
void nblob(Random& restrict engine, unsigned char* restrict output, size_t es, size_t l)
|
|
|
|
|
{
|
|
|
|
|
size_t len = es * l; // full length (bytes)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
inline void nblob(Random& restrict engine, unsigned char* restrict output, size_t len) { nblob(engine, output, 1, len); }
|
|
|
|
|
|
|
|
|
|
constexpr inline size_t ty_sizeof(rng_next_type ty)
|
|
|
|
|
{
|
|
|
|
|
//TODO:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constexpr inline bool ty_signed(rng_next_flag f) { return ! (f & RNG_TYQ_UNSIGNED); }
|
|
|
|
|
constexpr inline bool ty_signed(const rng_next_tyq& qt) { return ty_signed(qt.mod); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
// Internal bridge members
|
|
|
|
|
_export(internal)
|
|
|
|
@ -17,7 +36,22 @@ extern "C" {
|
|
|
|
|
default: return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_export(internal)
|
|
|
|
|
int RNG_IMPL(mnext)(rng_t* restrict engine, void* restrict output, const rng_next_opt* restrict opt)
|
|
|
|
|
{
|
|
|
|
|
if(opt->ty.mod & RNG_TYQ_CHAOS) {
|
|
|
|
|
bridge::nblob(*engine, reinterpret_cast<unsigned char*>(output), bridge::ty_sizeof(opt->ty.type), opt->bound.len);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch(opt->ty.type)
|
|
|
|
|
{
|
|
|
|
|
case RNG_TY_BLOB: bridge::nblob(*engine, reinterpret_cast<unsigned char*>(output), opt->bound.len); break;
|
|
|
|
|
//TODO: Rest of types
|
|
|
|
|
default: return 0;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Direct C interface members
|
|
|
|
|
void rng_free(rng_t* rng)
|
|
|
|
|