| 3850 | } |
| 3851 | |
| 3852 | dsc* 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 | |
| 3883 | dsc* evlRsaPublic(thread_db* tdbb, const SysFunction* function, const NestValueArray& args, impure_value* impure) |
| 3884 | { |
nothing calls this directly
no test coverage detected