aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public_key/src/public_key.erl
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2013-04-16 11:48:25 +0200
committerIngela Anderton Andin <[email protected]>2013-05-08 10:39:18 +0200
commit7030e089d1090e3b9a95c96737b36d6d6fc6ef97 (patch)
treeb06b9d2286f2cac23a2a9e86de3b03d45c62a617 /lib/public_key/src/public_key.erl
parent07ba72cdef3d9b62b5be23611cfe869ec343cb87 (diff)
downloadotp-7030e089d1090e3b9a95c96737b36d6d6fc6ef97.tar.gz
otp-7030e089d1090e3b9a95c96737b36d6d6fc6ef97.tar.bz2
otp-7030e089d1090e3b9a95c96737b36d6d6fc6ef97.zip
public_key: Eliminate mpints in rsa_public/private_encrypt/decrypt
Diffstat (limited to 'lib/public_key/src/public_key.erl')
-rw-r--r--lib/public_key/src/public_key.erl36
1 files changed, 12 insertions, 24 deletions
diff --git a/lib/public_key/src/public_key.erl b/lib/public_key/src/public_key.erl
index 91d33fab42..4b8fda8d40 100644
--- a/lib/public_key/src/public_key.erl
+++ b/lib/public_key/src/public_key.erl
@@ -253,10 +253,9 @@ decrypt_private(CipherText,
privateExponent = D} = Key,
Options)
when is_binary(CipherText),
- is_integer(N), is_integer(E), is_integer(D),
is_list(Options) ->
Padding = proplists:get_value(rsa_pad, Options, rsa_pkcs1_padding),
- crypto:rsa_private_decrypt(CipherText, old_format_rsa_private_key(Key), Padding).
+ crypto:rsa_private_decrypt(CipherText, format_rsa_private_key(Key), Padding).
%%--------------------------------------------------------------------
-spec decrypt_public(CipherText :: binary(), rsa_public_key() | rsa_private_key()) ->
@@ -320,36 +319,25 @@ encrypt_private(PlainText,
Options)
when is_binary(PlainText),
is_integer(N), is_integer(E), is_integer(D),
- is_list(Options) ->
+ is_list(Options) ->
Padding = proplists:get_value(rsa_pad, Options, rsa_pkcs1_padding),
- crypto:rsa_private_encrypt(PlainText, old_format_rsa_private_key(Key), Padding).
-
+ crypto:rsa_private_encrypt(PlainText, format_rsa_private_key(Key), Padding).
format_rsa_private_key(#'RSAPrivateKey'{modulus = N, publicExponent = E,
privateExponent = D,
prime1 = P1, prime2 = P2,
exponent1 = E1, exponent2 = E2,
coefficient = C})
- when is_integer(P1), is_integer(P2),
+ when is_integer(N), is_integer(E), is_integer(D),
+ is_integer(P1), is_integer(P2),
is_integer(E1), is_integer(E2), is_integer(C) ->
- [K || K <- [E, N, D, P1, P2, E1, E2, C]];
+ [E, N, D, P1, P2, E1, E2, C];
format_rsa_private_key(#'RSAPrivateKey'{modulus = N, publicExponent = E,
- privateExponent = D}) ->
- [K || K <- [E, N, D]].
-
-old_format_rsa_private_key(#'RSAPrivateKey'{modulus = N, publicExponent = E,
- privateExponent = D,
- prime1 = P1, prime2 = P2,
- exponent1 = E1, exponent2 = E2,
- coefficient = C})
- when is_integer(P1), is_integer(P2),
- is_integer(E1), is_integer(E2), is_integer(C) ->
- [crypto:mpint(K) || K <- [E, N, D, P1, P2, E1, E2, C]];
-
-old_format_rsa_private_key(#'RSAPrivateKey'{modulus = N, publicExponent = E,
- privateExponent = D}) ->
- [crypto:mpint(K) || K <- [E, N, D]].
+ privateExponent = D}) when is_integer(N),
+ is_integer(E),
+ is_integer(D) ->
+ [E, N, D].
%%
%% Description: convert a ECPrivate key into resource Key
@@ -720,12 +708,12 @@ do_pem_entry_decode({Asn1Type,_, _} = PemEntry, Password) ->
encrypt_public(PlainText, N, E, Options)->
Padding = proplists:get_value(rsa_pad, Options, rsa_pkcs1_padding),
- crypto:rsa_public_encrypt(PlainText, [crypto:mpint(E),crypto:mpint(N)],
+ crypto:rsa_public_encrypt(PlainText, [E,N],
Padding).
decrypt_public(CipherText, N,E, Options) ->
Padding = proplists:get_value(rsa_pad, Options, rsa_pkcs1_padding),
- crypto:rsa_public_decrypt(CipherText,[crypto:mpint(E), crypto:mpint(N)],
+ crypto:rsa_public_decrypt(CipherText,[E, N],
Padding).
path_validation([], #path_validation_state{working_public_key_algorithm