aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/src/misc/snmp_misc.erl
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2013-05-28 16:56:44 +0200
committerMicael Karlberg <[email protected]>2013-05-28 16:56:44 +0200
commit6aca7052709ea0f88503b08685c1699845a6de89 (patch)
treeeb5adbabbb2e40d6909f3d0511f239b827c7c374 /lib/snmp/src/misc/snmp_misc.erl
parent80c02173c9fc1d76ac1b404a05e2706817a4c308 (diff)
downloadotp-6aca7052709ea0f88503b08685c1699845a6de89.tar.gz
otp-6aca7052709ea0f88503b08685c1699845a6de89.tar.bz2
otp-6aca7052709ea0f88503b08685c1699845a6de89.zip
[snmp] Use of new crypto interface correctd in manager
Added a common utility function (in the snmp_misc module) for testing for crypto support (sed both by the manager and agent code). OTP-11009
Diffstat (limited to 'lib/snmp/src/misc/snmp_misc.erl')
-rw-r--r--lib/snmp/src/misc/snmp_misc.erl17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/snmp/src/misc/snmp_misc.erl b/lib/snmp/src/misc/snmp_misc.erl
index a061dcd97c..293b22991b 100644
--- a/lib/snmp/src/misc/snmp_misc.erl
+++ b/lib/snmp/src/misc/snmp_misc.erl
@@ -43,6 +43,7 @@
ip/1, ip/2,
is_auth/1,
is_BitString/1,
+ is_crypto_supported/1,
is_oid/1,
is_priv/1,
is_reportable/1,
@@ -117,13 +118,27 @@ now(sec) ->
(element(3,Now) div 1000000).
+is_crypto_supported(Alg) ->
+ %% The 'try catch' handles the case when 'crypto' is
+ %% not present in the system (or not started).
+ try
+ begin
+ Supported = crypto:supports(),
+ Hashs = proplists:get_value(hashs, Supported),
+ Ciphers = proplists:get_value(ciphers, Supported),
+ lists:member(Alg, Hashs ++ Ciphers)
+ end
+ catch
+ _:_ ->
+ false
+ end.
+
is_string([]) -> true;
is_string([Tkn | Str])
when is_integer(Tkn) andalso (Tkn >= 0) andalso (Tkn =< 255) ->
is_string(Str);
is_string(_) -> false.
-
is_oid([E1, E2| Rest])
when (length(Rest) =< 126) andalso (E1 *40 + E2 =< 255) ->
is_oid2(Rest);