From fbaa5e3ddf028ba0e2b58a19609817ee17b10c6f Mon Sep 17 00:00:00 2001 From: Ingela Anderton Andin Date: Thu, 17 Mar 2011 18:30:57 +0100 Subject: Implemented encode/decode support for ssh public key files --- lib/public_key/doc/src/public_key.xml | 98 ++++++++++++++++++++++++++--------- 1 file changed, 73 insertions(+), 25 deletions(-) (limited to 'lib/public_key/doc') diff --git a/lib/public_key/doc/src/public_key.xml b/lib/public_key/doc/src/public_key.xml index 81aedaea56..c5f57214b1 100644 --- a/lib/public_key/doc/src/public_key.xml +++ b/lib/public_key/doc/src/public_key.xml @@ -56,44 +56,43 @@

Data Types

-

boolean() = true | false

+

boolean() = true | false

-

string = [bytes()]

+

string = [bytes()]

-

der_encoded() = binary()

- -

decrypt_der() = binary()

+

pki_asn1_type() = 'Certificate' | 'RSAPrivateKey'| 'RSAPublicKey' + 'DSAPrivateKey' | 'DSAPublicKey' | 'DHParameter' | 'SubjectPublicKeyInfo'

-

pki_asn1_type() = 'Certificate' | 'RSAPrivateKey'| 'RSAPublicKey' - 'DSAPrivateKey' | 'DSAPublicKey' | 'DHParameter' | 'SubjectPublicKeyInfo'

- -

pem_entry () = {pki_asn1_type(), der_encoded() | decrypt_der(), not_encrypted | - {"DES-CBC" | "DES-EDE3-CBC", crypto:rand_bytes(8)}}.

- -

rsa_public_key() = #'RSAPublicKey'{}

+

pem_entry () = {pki_asn1_type(), binary() %% DER or encrypted DER + not_encrypted | {"DES-CBC" | "DES-EDE3-CBC", crypto:rand_bytes(8)}}.

-

rsa_private_key() = #'RSAPrivateKey'{}

+

rsa_public_key() = #'RSAPublicKey'{}

+ +

rsa_private_key() = #'RSAPrivateKey'{}

-

dsa_public_key() = {integer(), #'Dss-Parms'{}}

+

dsa_public_key() = {integer(), #'Dss-Parms'{}}

-

rsa_private_key() = #'RSAPrivateKey'{}

+

rsa_private_key() = #'RSAPrivateKey'{}

-

dsa_private_key() = #'DSAPrivateKey'{}

+

dsa_private_key() = #'DSAPrivateKey'{}

-

public_crypt_options() = [{rsa_pad, rsa_padding()}].

+

public_crypt_options() = [{rsa_pad, rsa_padding()}].

-

rsa_padding() = 'rsa_pkcs1_padding' | 'rsa_pkcs1_oaep_padding' - | 'rsa_no_padding'

+

rsa_padding() = 'rsa_pkcs1_padding' | 'rsa_pkcs1_oaep_padding' + | 'rsa_no_padding'

-

rsa_digest_type() = 'md5' | 'sha'

- -

dss_digest_type() = 'none' | 'sha'

+

rsa_digest_type() = 'md5' | 'sha'

+ +

dss_digest_type() = 'none' | 'sha'

+ +

ssh_file() = openssh_public_key | rfc4716_public_key | + known_hosts | auth_keys

- + - + - + @@ -402,6 +401,55 @@ + + ssh_decode(SshBin, Type) -> [{public_key(), Attributes::list()}] + Decodes a ssh file-binary. + + SshBin = binary() + Example {ok, SshBin} = file:read_file("known_hosts"). + Type = public_key | ssh_file() + If Type is public_key the binary may be either + a rfc4716 public key or a openssh public key. + + +

Decodes a ssh file-binary. In the case of know_hosts or + auth_keys the binary may include one or more lines of the + file. Returns a list of public keys and their attributes, possible + attribute values depends on the file type represented by the + binary. +

+ + + rfc4716 attributes - see RFC 4716 + {headers, [{string(), utf8_string()}]} + auth_key attributes - see man sshd + {comment, string()} + {options, [string()]} + {bits, integer()} - In ssh version 1 files + known_host attributes - see man sshd + {hostnames, [string()]} + {comment, string()} + {bits, integer()} - In ssh version 1 files + + +
+
+ + + ssh_encode([{Key, Attributes}], Type) -> binary() + Encodes a list of ssh file entries to a binary. + + Key = public_key() + Attributes = list() + Type = ssh_file() + + +

Encodes a list of ssh file entries (public keys and attributes) to a binary. Possible + attributes depends on the file type, see ssh_decode/2

+
+
+ verify(Msg, DigestType, Signature, Key) -> boolean() Verifies a digital signature. -- cgit v1.2.3