aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2013-05-28 09:22:12 +0200
committerIngela Anderton Andin <[email protected]>2013-05-28 09:22:12 +0200
commit7f5fa1b06671d31476e0fc0f28b878a6b5059b1b (patch)
treeeaaecc247d03c90cb46fc3f9f2f2c085f9c653c0 /lib/compiler
parent58de241d5d8e4b0536389b317ecc6e7a2a570997 (diff)
parent6ec1399aa8e6f80d8423acc37027eeda4394e7ad (diff)
downloadotp-7f5fa1b06671d31476e0fc0f28b878a6b5059b1b.tar.gz
otp-7f5fa1b06671d31476e0fc0f28b878a6b5059b1b.tar.bz2
otp-7f5fa1b06671d31476e0fc0f28b878a6b5059b1b.zip
Merge branch 'ia/ssl/public_key/crypto/elliptic_curve/OTP-11009' into maint
* ia/ssl/public_key/crypto/elliptic_curve/OTP-11009: (21 commits) ssl: Do not advertise EC ciphers if crypto support is insufficient crypto: Ctify tests and test new API crypto: Allow integer as srp_private arguments according to docs ssl: Remove unused `srp_parameters` type spec crypto, public_key & ssl: Make more functions accept integer keys snmp: Remove use of deprecated crypto functions crypto,ssh, netconf, inets: binary_to_integer -> bytes_to_integer netconf: Remove use of deprecated crypto functions crypto: Documentation fixes from review crypto: Change argument order of crypto:next_iv/3 crypto,public_key,ssl: Change return value of crypto:generate_key(ecdh,..) ssl, public_key, crypto: crypto:algorithms/0 -> crypto:supports/0 ssl, public_key & inets: Remove use of deprecated crypto functions from test code ssl: Remove use of deprecated crypto functions public_key: Remove use of deprecated crypto functions dialyzer: Remove use of deprecated crypto functions ssh & crypto: Remove use of deprecated crypto functions from ssh Update primary bootstrap common_test: Replace use of deprecated crypto functions beam_lib, compile: Replace use of deprecated crypto functions ...
Diffstat (limited to 'lib/compiler')
-rw-r--r--lib/compiler/src/compile.erl20
-rw-r--r--lib/compiler/test/compile_SUITE.erl10
-rw-r--r--lib/compiler/test/compile_SUITE_data/key_compatibility.beambin0 -> 844 bytes
-rw-r--r--lib/compiler/test/compile_SUITE_data/key_compatibility.erl8
4 files changed, 28 insertions, 10 deletions
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl
index 745f1d5cf9..2ca403de54 100644
--- a/lib/compiler/src/compile.erl
+++ b/lib/compiler/src/compile.erl
@@ -1197,9 +1197,9 @@ abstract_code(#compile{code=Code,options=Opts,ofile=OFile}) ->
encrypt_abs_code(Abstr, Key0) ->
try
- {Mode,RealKey} = generate_key(Key0),
+ RealKey = generate_key(Key0),
case start_crypto() of
- ok -> {ok,encrypt(Mode, RealKey, Abstr)};
+ ok -> {ok,encrypt(RealKey, Abstr)};
{error,_}=E -> E
end
catch
@@ -1216,19 +1216,19 @@ start_crypto() ->
{error,[{none,?MODULE,no_crypto}]}
end.
-generate_key({Mode,String}) when is_atom(Mode), is_list(String) ->
- {Mode,beam_lib:make_crypto_key(Mode, String)};
+generate_key({Type,String}) when is_atom(Type), is_list(String) ->
+ beam_lib:make_crypto_key(Type, String);
generate_key(String) when is_list(String) ->
generate_key({des3_cbc,String}).
-encrypt(des3_cbc=Mode, {K1,K2,K3, IVec}, Bin0) ->
- Bin1 = case byte_size(Bin0) rem 8 of
+encrypt({des3_cbc=Type,Key,IVec,BlockSize}, Bin0) ->
+ Bin1 = case byte_size(Bin0) rem BlockSize of
0 -> Bin0;
- N -> list_to_binary([Bin0,random_bytes(8-N)])
+ N -> list_to_binary([Bin0,random_bytes(BlockSize-N)])
end,
- Bin = crypto:des3_cbc_encrypt(K1, K2, K3, IVec, Bin1),
- ModeString = atom_to_list(Mode),
- list_to_binary([0,length(ModeString),ModeString,Bin]).
+ Bin = crypto:block_encrypt(Type, Key, IVec, Bin1),
+ TypeString = atom_to_list(Type),
+ list_to_binary([0,length(TypeString),TypeString,Bin]).
random_bytes(N) ->
{A,B,C} = now(),
diff --git a/lib/compiler/test/compile_SUITE.erl b/lib/compiler/test/compile_SUITE.erl
index 229e5a98a1..c635d13c89 100644
--- a/lib/compiler/test/compile_SUITE.erl
+++ b/lib/compiler/test/compile_SUITE.erl
@@ -492,6 +492,16 @@ encrypted_abstr_1(Simple, Target) ->
?line {error,beam_lib,{key_missing_or_invalid,"simple.beam",abstract_code}} =
beam_lib:chunks("simple.beam", [abstract_code]),
?line ok = file:set_cwd(OldCwd),
+
+ %% Test key compatibility by reading a BEAM file produced before
+ %% the update to the new crypto functions.
+ install_crypto_key("an old key"),
+ KeyCompat = filename:join(filename:dirname(Simple),
+ "key_compatibility"),
+ {ok,{key_compatibility,[Chunk]}} = beam_lib:chunks(KeyCompat,
+ [abstract_code]),
+ {abstract_code,{raw_abstract_v1,_}} = Chunk,
+
ok.
diff --git a/lib/compiler/test/compile_SUITE_data/key_compatibility.beam b/lib/compiler/test/compile_SUITE_data/key_compatibility.beam
new file mode 100644
index 0000000000..28329d2423
--- /dev/null
+++ b/lib/compiler/test/compile_SUITE_data/key_compatibility.beam
Binary files differ
diff --git a/lib/compiler/test/compile_SUITE_data/key_compatibility.erl b/lib/compiler/test/compile_SUITE_data/key_compatibility.erl
new file mode 100644
index 0000000000..e2931f1b12
--- /dev/null
+++ b/lib/compiler/test/compile_SUITE_data/key_compatibility.erl
@@ -0,0 +1,8 @@
+-module(key_compatibility).
+-export([main/0]).
+
+%% Compile like this:
+%% erlc +'{debug_info_key,"an old key"}' key_compatibility.erl
+
+main() ->
+ ok.