diff options
author | Hans Nilsson <[email protected]> | 2017-11-10 12:28:34 +0100 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2017-11-10 12:28:34 +0100 |
commit | 4d9d6776aadee9e0d27b34460fa5269a6b6988aa (patch) | |
tree | 43b1b9394e75b19fb12124234505deb3841748c1 /lib/crypto/src | |
parent | 1d0bd5f30cfd95d0977061618a5e483a8606deca (diff) | |
parent | 82a47ae5c388030d6e13b44cc23b6c1639812ad5 (diff) | |
download | otp-4d9d6776aadee9e0d27b34460fa5269a6b6988aa.tar.gz otp-4d9d6776aadee9e0d27b34460fa5269a6b6988aa.tar.bz2 otp-4d9d6776aadee9e0d27b34460fa5269a6b6988aa.zip |
Merge branch 'hans/ssh/hostkey_in_engine/OTP-14757' into maint
Diffstat (limited to 'lib/crypto/src')
-rw-r--r-- | lib/crypto/src/crypto.erl | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl index 7510babdde..0d39dcc76e 100644 --- a/lib/crypto/src/crypto.erl +++ b/lib/crypto/src/crypto.erl @@ -42,6 +42,7 @@ -export([public_encrypt/4, private_decrypt/4]). -export([private_encrypt/4, public_decrypt/4]). -export([dh_generate_parameters/2, dh_check/1]). %% Testing see +-export([privkey_to_pubkey/2]). -export([ec_curve/1, ec_curves/0]). -export([rand_seed/1]). %% Engine @@ -1058,6 +1059,16 @@ ec_curves() -> ec_curve(X) -> crypto_ec_curves:curve(X). + +privkey_to_pubkey(Alg, EngineMap) when Alg == rsa; Alg == dss; Alg == ecdsa -> + case privkey_to_pubkey_nif(Alg, format_pkey(Alg,EngineMap)) of + [_|_]=L -> map_ensure_bin_as_int(L); + X -> X + end. + +privkey_to_pubkey_nif(_Alg, _EngineMap) -> ?nif_stub. + + %% %% EC %% @@ -1125,6 +1136,14 @@ ensure_int_as_bin(Int) when is_integer(Int) -> ensure_int_as_bin(Bin) -> Bin. +map_ensure_bin_as_int(List) when is_list(List) -> + lists:map(fun ensure_bin_as_int/1, List). + +ensure_bin_as_int(Bin) when is_binary(Bin) -> + bin_to_int(Bin); +ensure_bin_as_int(E) -> + E. + format_pkey(_Alg, #{engine:=_, key_id:=T}=M) when is_binary(T) -> format_pwd(M); format_pkey(_Alg, #{engine:=_, key_id:=T}=M) when is_list(T) -> format_pwd(M#{key_id:=list_to_binary(T)}); format_pkey(_Alg, #{engine:=_ }=M) -> error({bad_key_id, M}); |