diff options
Diffstat (limited to 'lib/stdlib')
-rw-r--r-- | lib/stdlib/doc/src/c.xml | 4 | ||||
-rw-r--r-- | lib/stdlib/src/beam_lib.erl | 16 | ||||
-rw-r--r-- | lib/stdlib/src/c.erl | 6 | ||||
-rw-r--r-- | lib/stdlib/src/otp_internal.erl | 72 | ||||
-rw-r--r-- | lib/stdlib/test/c_SUITE.erl | 11 |
5 files changed, 81 insertions, 28 deletions
diff --git a/lib/stdlib/doc/src/c.xml b/lib/stdlib/doc/src/c.xml index ddae388a1b..9cd4581a89 100644 --- a/lib/stdlib/doc/src/c.xml +++ b/lib/stdlib/doc/src/c.xml @@ -140,9 +140,9 @@ compile:file(<anno>File</anno>, <anno>Options</anno> ++ [report_errors, report_w </func> <func> <name name="ls" arity="1"/> - <fsummary>List files in a directory</fsummary> + <fsummary>List files in a directory or a single file</fsummary> <desc> - <p>Lists files in directory <c><anno>Dir</anno></c>.</p> + <p>Lists files in directory <c><anno>Dir</anno></c> or, if Dir is a file, only list it.</p> </desc> </func> <func> diff --git a/lib/stdlib/src/beam_lib.erl b/lib/stdlib/src/beam_lib.erl index fe7e0f8e60..2e9ebece0e 100644 --- a/lib/stdlib/src/beam_lib.erl +++ b/lib/stdlib/src/beam_lib.erl @@ -302,10 +302,10 @@ clear_crypto_key_fun() -> -spec make_crypto_key(mode(), string()) -> {binary(), binary(), binary(), binary()}. -make_crypto_key(des3_cbc, String) -> +make_crypto_key(des3_cbc=Type, String) -> <<K1:8/binary,K2:8/binary>> = First = erlang:md5(String), <<K3:8/binary,IVec:8/binary>> = erlang:md5([First|reverse(String)]), - {K1,K2,K3,IVec}. + {Type,[K1,K2,K3],IVec,8}. %% %% Local functions @@ -864,20 +864,20 @@ mandatory_chunks() -> -define(CRYPTO_KEY_SERVER, beam_lib__crypto_key_server). -decrypt_abst(Mode, Module, File, Id, AtomTable, Bin) -> +decrypt_abst(Type, Module, File, Id, AtomTable, Bin) -> try - KeyString = get_crypto_key({debug_info, Mode, Module, File}), - Key = make_crypto_key(des3_cbc, KeyString), - Term = decrypt_abst_1(Mode, Key, Bin), + KeyString = get_crypto_key({debug_info, Type, Module, File}), + Key = make_crypto_key(Type, KeyString), + Term = decrypt_abst_1(Key, Bin), {AtomTable, {Id, Term}} catch _:_ -> error({key_missing_or_invalid, File, Id}) end. -decrypt_abst_1(des3_cbc, {K1, K2, K3, IVec}, Bin) -> +decrypt_abst_1({Type,Key,IVec,_BlockSize}, Bin) -> ok = start_crypto(), - NewBin = crypto:des3_cbc_decrypt(K1, K2, K3, IVec, Bin), + NewBin = crypto:block_decrypt(Type, Key, IVec, Bin), binary_to_term(NewBin). start_crypto() -> diff --git a/lib/stdlib/src/c.erl b/lib/stdlib/src/c.erl index 91d317489c..6e96e3d564 100644 --- a/lib/stdlib/src/c.erl +++ b/lib/stdlib/src/c.erl @@ -713,8 +713,10 @@ ls(Dir) -> case file:list_dir(Dir) of {ok, Entries} -> ls_print(sort(Entries)); - {error,_E} -> - format("Invalid directory\n") + {error, enotdir} -> + ls_print([Dir]); + {error, Error} -> + format("~s\n", [file:format_error(Error)]) end. ls_print([]) -> ok; diff --git a/lib/stdlib/src/otp_internal.erl b/lib/stdlib/src/otp_internal.erl index f2849e50ec..42a42b7fd7 100644 --- a/lib/stdlib/src/otp_internal.erl +++ b/lib/stdlib/src/otp_internal.erl @@ -75,18 +75,18 @@ obsolete_1(crypto, md5, 1) -> obsolete_1(crypto, sha, 1) -> {deprecated, {crypto, hash, 2}}; -obsolete_1(crypto, md4_init, 1) -> - {deprecated, {crypto, hash_init, 2}}; -obsolete_1(crypto, md5_init, 1) -> - {deprecated, {crypto, hash_init, 2}}; -obsolete_1(crypto, sha_init, 1) -> - {deprecated, {crypto, hash_init, 2}}; +obsolete_1(crypto, md4_init, 0) -> + {deprecated, {crypto, hash_init, 1}}; +obsolete_1(crypto, md5_init, 0) -> + {deprecated, {crypto, hash_init, 1}}; +obsolete_1(crypto, sha_init, 0) -> + {deprecated, {crypto, hash_init, 1}}; obsolete_1(crypto, md4_update, 2) -> {deprecated, {crypto, hash_update, 3}}; obsolete_1(crypto, md5_update, 2) -> {deprecated, {crypto, hash_update, 3}}; -obsolete_1(crypto, sah_update, 2) -> +obsolete_1(crypto, sha_update, 2) -> {deprecated, {crypto, hash_update, 3}}; obsolete_1(crypto, md4_final, 1) -> @@ -100,16 +100,22 @@ obsolete_1(crypto, md5_mac, 2) -> {deprecated, {crypto, hmac, 3}}; obsolete_1(crypto, sha_mac, 2) -> {deprecated, {crypto, hmac, 3}}; +obsolete_1(crypto, sha_mac, 3) -> + {deprecated, {crypto, hmac, 4}}; obsolete_1(crypto, sha_mac_96, 2) -> {deprecated, {crypto, hmac_n, 3}}; obsolete_1(crypto, md5_mac_96, 2) -> {deprecated, {crypto, hmac_n, 3}}; +obsolete_1(crypto, rsa_sign, 2) -> + {deprecated, {crypto, sign, 4}}; obsolete_1(crypto, rsa_sign, 3) -> {deprecated, {crypto, sign, 4}}; obsolete_1(crypto, rsa_verify, 3) -> - {deprecated, {crypto, verify, 4}}; + {deprecated, {crypto, verify, 5}}; +obsolete_1(crypto, rsa_verify, 4) -> + {deprecated, {crypto, verify, 5}}; obsolete_1(crypto, dss_sign, 2) -> {deprecated, {crypto, sign, 4}}; @@ -135,8 +141,8 @@ obsolete_1(crypto, des_cbc_encrypt, 3) -> {deprecated, {crypto, block_encrypt, 4}}; obsolete_1(crypto, des3_cbc_encrypt, 5) -> {deprecated, {crypto, block_encrypt, 4}}; -obsolete_1(crypto, des_ecb_encrypt, 3) -> - {deprecated, {crypto, block_encrypt, 4}}; +obsolete_1(crypto, des_ecb_encrypt, 2) -> + {deprecated, {crypto, block_encrypt, 3}}; obsolete_1(crypto, des_ede3_cbc_encrypt, 5) -> {deprecated, {crypto, block_encrypt, 4}}; obsolete_1(crypto, des_cfb_encrypt, 3) -> @@ -153,6 +159,8 @@ obsolete_1(crypto, blowfish_ofb64_encrypt, 3) -> {deprecated, {crypto, block_encrypt, 4}}; obsolete_1(crypto, aes_cfb_128_encrypt, 3) -> {deprecated, {crypto, block_encrypt, 4}}; +obsolete_1(crypto, aes_cbc_128_encrypt, 3) -> + {deprecated, {crypto, block_encrypt, 4}}; obsolete_1(crypto, aes_cbc_256_encrypt, 3) -> {deprecated, {crypto, block_encrypt, 4}}; obsolete_1(crypto,rc2_cbc_encrypt, 3) -> @@ -164,8 +172,8 @@ obsolete_1(crypto, des_cbc_decrypt, 3) -> {deprecated, {crypto, block_decrypt, 4}}; obsolete_1(crypto, des3_cbc_decrypt, 5) -> {deprecated, {crypto, block_decrypt, 4}}; -obsolete_1(crypto, des_ecb_decrypt, 3) -> - {deprecated, {crypto, block_decrypt, 4}}; +obsolete_1(crypto, des_ecb_decrypt, 2) -> + {deprecated, {crypto, block_decrypt, 3}}; obsolete_1(crypto, des_ede3_cbc_decrypt, 5) -> {deprecated, {crypto, block_decrypt, 4}}; obsolete_1(crypto, des_cfb_decrypt, 3) -> @@ -182,6 +190,8 @@ obsolete_1(crypto, blowfish_ofb64_decrypt, 3) -> {deprecated, {crypto, block_decrypt, 4}}; obsolete_1(crypto, aes_cfb_128_decrypt, 3) -> {deprecated, {crypto, block_decrypt, 4}}; +obsolete_1(crypto, aes_cbc_128_decrypt, 3) -> + {deprecated, {crypto, block_decrypt, 4}}; obsolete_1(crypto, aes_cbc_256_decrypt, 3) -> {deprecated, {crypto, block_decrypt, 4}}; obsolete_1(crypto,rc2_cbc_decrypt, 3) -> @@ -189,16 +199,50 @@ obsolete_1(crypto,rc2_cbc_decrypt, 3) -> obsolete_1(crypto,rc2_40_cbc_decrypt, 3) -> {deprecated, {crypto, block_decrypt, 4}}; +obsolete_1(crypto, aes_ctr_stream_decrypt, 2) -> + {deprecated, {crypto, stream_decrypt, 2}}; +obsolete_1(crypto, aes_ctr_stream_encrypt, 2) -> + {deprecated, {crypto, stream_encrypt, 2}}; +obsolete_1(crypto, aes_ctr_decrypt, 3) -> + {deprecated, {crypto, stream_decrypt, 2}}; +obsolete_1(crypto, aes_ctr_encrypt, 3) -> + {deprecated, {crypto, stream_encrypt, 2}}; +obsolete_1(crypto, rc4_encrypt, 2) -> + {deprecated, {crypto, stream_encrypt, 2}}; +obsolete_1(crypto, rc4_encrypt_with_state, 2) -> + {deprecated, {crypto, stream_encrypt, 2}}; +obsolete_1(crypto, aes_ctr_stream_init, 2) -> + {deprecated, {crypto, stream_init, 3}}; +obsolete_1(crypto, rc4_set_key, 1) -> + {deprecated, {crypto, stream_init, 2}}; + +obsolete_1(crypto, rsa_private_decrypt, 3) -> + {deprecated, {crypto, private_decrypt, 4}}; +obsolete_1(crypto, rsa_public_decrypt, 3) -> + {deprecated, {crypto, public_decrypt, 4}}; +obsolete_1(crypto, rsa_private_encrypt, 3) -> + {deprecated, {crypto, private_encrypt, 4}}; +obsolete_1(crypto, rsa_public_encrypt, 3) -> + {deprecated, {crypto, public_encrypt, 4}}; + +obsolete_1(crypto, des_cfb_ivec, 2) -> + {deprecated, {crypto, next_iv, 3}}; +obsolete_1(crypto,des_cbc_ivec, 1) -> + {deprecated, {crypto, next_iv, 2}}; +obsolete_1(crypto, aes_cbc_ivec, 1) -> + {deprecated, {crypto, next_iv, 2}}; + obsolete_1(crypto,info, 0) -> {deprecated, {crypto, module_info, 0}}; obsolete_1(crypto, strong_rand_mpint, 3) -> {deprecated, "needed only by deprecated functions"}; -obsolete_1(crypto, erlint, 3) -> +obsolete_1(crypto, erlint, 1) -> {deprecated, "needed only by deprecated functions"}; -obsolete_1(crypto, mpint, 3) -> +obsolete_1(crypto, mpint, 1) -> {deprecated, "needed only by deprecated functions"}; + %% *** SNMP *** obsolete_1(snmp, N, A) -> diff --git a/lib/stdlib/test/c_SUITE.erl b/lib/stdlib/test/c_SUITE.erl index 25281365be..8c55b616b9 100644 --- a/lib/stdlib/test/c_SUITE.erl +++ b/lib/stdlib/test/c_SUITE.erl @@ -20,7 +20,7 @@ -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, init_per_group/2,end_per_group/2]). -export([c_1/1, c_2/1, c_3/1, c_4/1, nc_1/1, nc_2/1, nc_3/1, nc_4/1, - memory/1]). + ls/1, memory/1]). -include_lib("test_server/include/test_server.hrl"). @@ -29,7 +29,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> - [c_1, c_2, c_3, c_4, nc_1, nc_2, nc_3, nc_4, memory]. + [c_1, c_2, c_3, c_4, nc_1, nc_2, nc_3, nc_4, ls, memory]. groups() -> []. @@ -147,6 +147,13 @@ nc_4(Config) when is_list(Config) -> ?line Result = nc(R,[{outdir,W}]), ?line {ok, m} = Result. +ls(Config) when is_list(Config) -> + Directory = ?config(data_dir, Config), + ok = c:ls(Directory), + File = filename:join(Directory, "m.erl"), + ok = c:ls(File), + ok = c:ls("no_such_file"). + memory(doc) -> ["Checks that c:memory/[0,1] returns consistent results."]; memory(suite) -> |