diff options
Diffstat (limited to 'lib/snmp/src/misc/snmp_usm.erl')
-rw-r--r-- | lib/snmp/src/misc/snmp_usm.erl | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/lib/snmp/src/misc/snmp_usm.erl b/lib/snmp/src/misc/snmp_usm.erl index 6d216e65d6..19be564a8e 100644 --- a/lib/snmp/src/misc/snmp_usm.erl +++ b/lib/snmp/src/misc/snmp_usm.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -206,6 +206,10 @@ des_encrypt(PrivKey, Data, SaltFun) -> des_decrypt(PrivKey, MsgPrivParams, EncData) when length(MsgPrivParams) =:= 8 -> + ?vtrace("des_decrypt -> entry with" + "~n PrivKey: ~p" + "~n MsgPrivParams: ~p" + "~n EncData: ~p", [PrivKey, MsgPrivParams, EncData]), [A,B,C,D,E,F,G,H | PreIV] = PrivKey, DesKey = [A,B,C,D,E,F,G,H], Salt = MsgPrivParams, @@ -213,7 +217,15 @@ des_decrypt(PrivKey, MsgPrivParams, EncData) %% Whatabout errors here??? E.g. not a mulitple of 8! Data = binary_to_list(crypto:des_cbc_decrypt(DesKey, IV, EncData)), Data2 = snmp_pdus:strip_encrypted_scoped_pdu_data(Data), - {ok, Data2}. + {ok, Data2}; +des_decrypt(PrivKey, BadMsgPrivParams, EncData) -> + ?vtrace("des_decrypt -> entry with when bad MsgPrivParams" + "~n PrivKey: ~p" + "~n BadMsgPrivParams: ~p" + "~n EncData: ~p", + [PrivKey, BadMsgPrivParams, EncData]), + throw({error, {bad_msgPrivParams, PrivKey, BadMsgPrivParams, EncData}}). + aes_encrypt(PrivKey, Data, SaltFun) -> AesKey = PrivKey, @@ -225,7 +237,7 @@ aes_encrypt(PrivKey, Data, SaltFun) -> {ok, binary_to_list(EncData), Salt}. aes_decrypt(PrivKey, MsgPrivParams, EncData, EngineBoots, EngineTime) - when length(MsgPrivParams) == 8 -> + when length(MsgPrivParams) =:= 8 -> AesKey = PrivKey, Salt = MsgPrivParams, IV = [?i32(EngineBoots), ?i32(EngineTime) | Salt], |