Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang
erlang
1534-snmp-Types-and-specs-for-snmp-passwd2local...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1534-snmp-Types-and-specs-for-snmp-passwd2localized_key-3.patch of Package erlang
From 15ec843f4b09a52cbe59b17f96ca8b87ddfec31d Mon Sep 17 00:00:00 2001 From: Micael Karlberg <bmk@erlang.org> Date: Wed, 10 Jan 2024 16:48:50 +0100 Subject: [PATCH 14/67] [snmp] Types and specs for snmp:passwd2localized_key/3 The 'algorithm()' type is actually defined in the snmp_usm module, but since we have no documentation for that module, we add that type to this module instead. --- lib/snmp/doc/src/snmp.xml | 20 ++++++++++++-------- lib/snmp/src/app/snmp.erl | 16 ++++++++++++++++ lib/snmp/src/misc/snmp_usm.erl | 12 ++++++++---- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/lib/snmp/doc/src/snmp.xml b/lib/snmp/doc/src/snmp.xml index c5e4e03f20..e5cb8eb3f8 100644 --- a/lib/snmp/doc/src/snmp.xml +++ b/lib/snmp/doc/src/snmp.xml @@ -141,6 +141,17 @@ </desc> </datatype> + <datatype> + <name name="algorithm"/> + <!-- + <desc> + <p> + TBD + </p> + </desc> + --> + </datatype> + </datatypes> <section> @@ -370,15 +381,8 @@ </func> <func> - <name since="">passwd2localized_key(Alg, Passwd, EngineID) -> Key</name> + <name name="passwd2localized_key" arity="3" clause_i="1" since=""/> <fsummary>Generates an localized key</fsummary> - <type> - <v>Alg = algorithm()</v> - <v>algorithm() = md5 | sha | sha224 | sha256 | sha384 | sha512</v> - <v>Passwd = string()</v> - <v>EngineID = string()</v> - <v>Key = list()</v> - </type> <desc> <p>Generates a key that can be used as an authentication or privacy key using MD5, SHA, SHA224, SHA256, SHA384 or SHA512. diff --git a/lib/snmp/src/app/snmp.erl b/lib/snmp/src/app/snmp.erl index 6d2bac2a09..812f4208d2 100644 --- a/lib/snmp/src/app/snmp.erl +++ b/lib/snmp/src/app/snmp.erl @@ -181,6 +181,9 @@ 'inform-request' | 'report'. +-type algorithm() :: md5 | sha | sha224 | sha256 | sha384 | sha512. + + %% We should really specify all of these, but they are so numerous... %% See the validate_err/1 function in the snmpa_agent. %% Here are a number of them: @@ -940,9 +943,22 @@ bits_to_octet_string(B) -> %%% USM functions %%%----------------------------------------------------------------- +-spec passwd2localized_key(Algorithm, Passwd, EngineID) -> Key when + Algorithm :: algorithm(), + Passwd :: string(), + EngineID :: string(), + Key :: list(). + passwd2localized_key(Alg, Passwd, EngineID) -> snmp_usm:passwd2localized_key(Alg, Passwd, EngineID). + +-spec localize_key(Algorithm, Key, EngineID) -> LKey when + Algorithm :: algorithm(), + Key :: binary(), + EngineID :: string(), + LKey :: list(). + localize_key(Alg, Key, EngineID) -> snmp_usm:localize_key(Alg, Key, EngineID). diff --git a/lib/snmp/src/misc/snmp_usm.erl b/lib/snmp/src/misc/snmp_usm.erl index 9c05c7d616..1c90609c07 100644 --- a/lib/snmp/src/misc/snmp_usm.erl +++ b/lib/snmp/src/misc/snmp_usm.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2004-2021. All Rights Reserved. +%% Copyright Ericsson AB 2004-2024. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -29,6 +29,10 @@ -export([des_encrypt/3, des_decrypt/3]). -export([aes_encrypt/5, aes_decrypt/5]). +-export_type([ + algorithm/0 + ]). + -define(SNMP_USE_V3, true). -include("snmp_types.hrl"). @@ -63,10 +67,12 @@ -define(BLOCK_CIPHER_DES, des_cbc). +-type algorithm() :: md5 | sha | sha224 | sha256 | sha384 | sha512. + %%----------------------------------------------------------------- %% Func: passwd2localized_key/3 -%% Types: Alg = md5 | sha +%% Types: Alg = algorithm() %% Passwd = string() %% EngineID = string() %% Purpose: Generates a key that can be used as an authentication @@ -76,8 +82,6 @@ %% rfc2274. %%----------------------------------------------------------------- --type algorithm() :: md5 | sha | sha224 | sha256 | sha384 | sha512. - -spec passwd2localized_key(Alg :: algorithm(), Passwd :: string(), EngineID :: string()) -> -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor