MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / evlRsaPrivate

Function evlRsaPrivate

src/jrd/SysFunction.cpp:3852–3881  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3850}
3851
3852dsc* evlRsaPrivate(thread_db* tdbb, const SysFunction* function, const NestValueArray& args, impure_value* impure)
3853{
3854 tomcryptInitializer();
3855
3856 fb_assert(args.getCount() == 1);
3857
3858 Request* request = tdbb->getRequest();
3859
3860 const dsc* value = EVL_expr(tdbb, request, args[0]);
3861 if (request->req_flags & req_null) // return NULL if value is NULL
3862 return NULL;
3863
3864 const SLONG length = MOV_get_long(tdbb, value, 0);
3865 if (length < 1 || length > 1024)
3866 status_exception::raise(Arg::Gds(isc_arith_except) << Arg::Gds(isc_numeric_out_of_range));
3867
3868 rsa_key rsaKey;
3869 tomCheck(rsa_make_key(prng().getState(), prng().getIndex(), length, 65537, &rsaKey), Arg::Gds(isc_tom_rsa_make));
3870
3871 unsigned long outlen = length * 16;
3872 UCharBuffer key;
3873 int cryptRc = rsa_export(key.getBuffer(outlen), &outlen, PK_PRIVATE, &rsaKey);
3874 rsa_free(&rsaKey);
3875 tomCheck(cryptRc, Arg::Gds(isc_tom_rsa_export) << "private");
3876
3877 dsc result;
3878 result.makeText(outlen, ttype_binary, key.begin());
3879 EVL_make_value(tdbb, &result, impure);
3880 return &impure->vlu_desc;
3881}
3882
3883dsc* evlRsaPublic(thread_db* tdbb, const SysFunction* function, const NestValueArray& args, impure_value* impure)
3884{

Callers

nothing calls this directly

Calls 15

EVL_exprFunction · 0.85
MOV_get_longFunction · 0.85
raiseFunction · 0.85
GdsClass · 0.85
rsa_make_keyFunction · 0.85
rsa_exportFunction · 0.85
rsa_freeFunction · 0.85
EVL_make_valueFunction · 0.85
getIndexMethod · 0.80
makeTextMethod · 0.80
tomCheckFunction · 0.70
getCountMethod · 0.45

Tested by

no test coverage detected