From 255f36937752404038f32ca67f438f13ef8ce4fb Mon Sep 17 00:00:00 2001 From: Hans Nilsson Date: Thu, 15 Oct 2015 10:25:19 +0200 Subject: public_key: add/update -spec for ssh functions --- lib/public_key/src/pubkey_ssh.erl | 8 ++++++-- lib/public_key/src/public_key.erl | 14 +++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'lib/public_key/src') diff --git a/lib/public_key/src/pubkey_ssh.erl b/lib/public_key/src/pubkey_ssh.erl index ba67abb4eb..82042550a0 100644 --- a/lib/public_key/src/pubkey_ssh.erl +++ b/lib/public_key/src/pubkey_ssh.erl @@ -41,7 +41,9 @@ %%-------------------------------------------------------------------- -spec decode(binary(), public_key | public_key:ssh_file()) -> - [{public_key:public_key(), Attributes::list()}]. + [{public_key:public_key(), Attributes::list()}] + ; (binary(), ssh2_pubkey) -> public_key:public_key() + . %% %% Description: Decodes a ssh file-binary. %%-------------------------------------------------------------------- @@ -61,7 +63,9 @@ decode(Bin, Type) -> %%-------------------------------------------------------------------- -spec encode([{public_key:public_key(), Attributes::list()}], public_key:ssh_file()) -> - binary(). + binary() + ; (public_key:public_key(), ssh2_pubkey) -> binary() + . %% %% Description: Encodes a list of ssh file entries. %%-------------------------------------------------------------------- diff --git a/lib/public_key/src/public_key.erl b/lib/public_key/src/public_key.erl index 941ade3dd7..8288f68f7f 100644 --- a/lib/public_key/src/public_key.erl +++ b/lib/public_key/src/public_key.erl @@ -712,7 +712,9 @@ pkix_crls_validate(OtpCert, DPAndCRLs0, Options) -> %%-------------------------------------------------------------------- --spec ssh_decode(binary(), public_key | ssh_file()) -> [{public_key(), Attributes::list()}]. +-spec ssh_decode(binary(), public_key | ssh_file()) -> [{public_key(), Attributes::list()}] + ; (binary(), ssh2_pubkey) -> public_key() + . %% %% Description: Decodes a ssh file-binary. In the case of know_hosts %% or auth_keys the binary may include one or more lines of the @@ -730,8 +732,10 @@ ssh_decode(SshBin, Type) when is_binary(SshBin), pubkey_ssh:decode(SshBin, Type). %%-------------------------------------------------------------------- --spec ssh_encode([{public_key(), Attributes::list()}], ssh_file()) -> - binary(). +-spec ssh_encode([{public_key(), Attributes::list()}], ssh_file()) -> binary() + ; (public_key(), ssh2_pubkey) -> binary() + . +%% %% Description: Encodes a list of ssh file entries (public keys and %% attributes) to a binary. Possible attributes depends on the file %% type. @@ -745,6 +749,8 @@ ssh_encode(Entries, Type) when is_list(Entries), pubkey_ssh:encode(Entries, Type). %%-------------------------------------------------------------------- +-spec ssh_curvename2oid(binary()) -> oid(). + %% Description: Converts from the ssh name of elliptic curves to %% the OIDs. %%-------------------------------------------------------------------- @@ -753,6 +759,8 @@ ssh_curvename2oid(<<"nistp384">>) -> ?'secp384r1'; ssh_curvename2oid(<<"nistp521">>) -> ?'secp521r1'. %%-------------------------------------------------------------------- +-spec oid2ssh_curvename(oid()) -> binary(). + %% Description: Converts from elliptic curve OIDs to the ssh name. %%-------------------------------------------------------------------- oid2ssh_curvename(?'secp256r1') -> <<"nistp256">>; -- cgit v1.2.3