From 178501a23a5a40edae2ee40e17a13c149a8b7c3a Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Thu, 12 Dec 2013 12:29:38 +0100 Subject: [PATCH 1/4] Fix incorrect proplists type reference ssh and public_key were referring to proplists:proplists/0 which does not exist. Fix by using the correct type proplists:proplist/0. --- lib/public_key/doc/src/public_key.xml | 4 ++-- lib/ssh/src/ssh.erl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/public_key/doc/src/public_key.xml b/lib/public_key/doc/src/public_key.xml index bce6d586828f..2f7e7a3d4d09 100644 --- a/lib/public_key/doc/src/public_key.xml +++ b/lib/public_key/doc/src/public_key.xml @@ -430,7 +430,7 @@ constructing the input to this function and that should be run through the verify_fun. CertChain = [der_encode()] A list of DER encoded certificates in trust order ending with the peer certificate. - Options = proplists:proplists() + Options = proplists:proplist() PublicKeyInfo = {?'rsaEncryption' | ?'id-dsa', rsa_public_key() | integer(), 'NULL' | 'Dss-Parms'{}} PolicyTree = term() @@ -492,7 +492,7 @@ fun(OtpCert :: #'OTPCertificate'{}, Event :: {bad_cert, Reason :: atom()} | OTPCertificate = #'OTPCertificate'{} DPAndCRLs = [{DP::#'DistributionPoint'{} ,CRL::#'CertificateList'{}}] - Options = proplists:proplists() + Options = proplists:proplist() CRLStatus() = valid | {bad_cert, revocation_status_undetermined} | {bad_cert, {revoked, crl_reason()}} diff --git a/lib/ssh/src/ssh.erl b/lib/ssh/src/ssh.erl index 2685b1553b38..9f571adba25a 100644 --- a/lib/ssh/src/ssh.erl +++ b/lib/ssh/src/ssh.erl @@ -59,8 +59,8 @@ stop() -> application:stop(ssh). %%-------------------------------------------------------------------- --spec connect(string(), integer(), proplists:proplists()) -> {ok, pid()} | {error, term()}. --spec connect(string(), integer(), proplists:proplists(), timeout()) -> {ok, pid()} | {error, term()}. +-spec connect(string(), integer(), proplists:proplist()) -> {ok, pid()} | {error, term()}. +-spec connect(string(), integer(), proplists:proplist(), timeout()) -> {ok, pid()} | {error, term()}. %% %% Description: Starts an ssh connection. %%-------------------------------------------------------------------- From f616b2d44aff1a9dbf55beffcb6a1afd85fffa8b Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Thu, 12 Dec 2013 12:38:43 +0100 Subject: [PATCH 2/4] Fix incorrect use of public_key:private_key/0 type public_key:private_key/0 was referenced but undefined, and lib/ssl had a local definition of private_key/0. To fix that, make the following changes: * add public_key:private_key/0 type * document public_key/0 and private_key/0 * fix incorrect definitions and references --- lib/public_key/doc/src/public_key.xml | 2 ++ lib/public_key/include/public_key.hrl | 3 ++- lib/ssl/src/ssl_handshake.erl | 6 +++--- lib/ssl/src/ssl_internal.hrl | 1 - 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/public_key/doc/src/public_key.xml b/lib/public_key/doc/src/public_key.xml index 2f7e7a3d4d09..613fbd2f16c4 100644 --- a/lib/public_key/doc/src/public_key.xml +++ b/lib/public_key/doc/src/public_key.xml @@ -94,6 +94,8 @@

cipher_info() = {"RC2-CBC | "DES-CBC" | "DES-EDE3-CBC", crypto:rand_bytes(8)} | 'PBES2-params'}

+

public_key() = rsa_public_key() | dsa_public_key() | ec_public_key()

+

private_key() = rsa_public_key() | dsa_public_key() | ec_public_key()

rsa_public_key() = #'RSAPublicKey'{}

rsa_private_key() = #'RSAPrivateKey'{}

diff --git a/lib/public_key/include/public_key.hrl b/lib/public_key/include/public_key.hrl index 1e882e76ee35..8afc841fa64f 100644 --- a/lib/public_key/include/public_key.hrl +++ b/lib/public_key/include/public_key.hrl @@ -88,7 +88,8 @@ -define(privilegeWithdrawn, 9). -define(aACompromise, 10). --type public_key() :: rsa_public_key() | dsa_public_key(). +-type public_key() :: rsa_public_key() | dsa_public_key() | ec_public_key(). +-type private_key() :: rsa_private_key() | dsa_private_key() | ec_private_key(). -type rsa_public_key() :: #'RSAPublicKey'{}. -type rsa_private_key() :: #'RSAPrivateKey'{}. -type dsa_private_key() :: #'DSAPrivateKey'{}. diff --git a/lib/ssl/src/ssl_handshake.erl b/lib/ssl/src/ssl_handshake.erl index da72ffc04381..9d758068fbd0 100644 --- a/lib/ssl/src/ssl_handshake.erl +++ b/lib/ssl/src/ssl_handshake.erl @@ -164,7 +164,7 @@ next_protocol(SelectedProtocol) -> %%-------------------------------------------------------------------- -spec client_certificate_verify(undefined | der_cert(), binary(), - tls_version(), term(), private_key(), + tls_version(), term(), public_key:private_key(), tls_handshake_history()) -> #certificate_verify{} | ignore | #alert{}. %% @@ -207,12 +207,12 @@ certificate_request(CipherSuite, CertDbHandle, CertDbRef, Version) -> {premaster_secret, binary(), public_key_info()} | {dh, binary()} | {dh, {binary(), binary()}, #'DHParameter'{}, {HashAlgo::atom(), SignAlgo::atom()}, - binary(), binary(), private_key()} | + binary(), binary(), public_key:private_key()} | {ecdh, #'ECPrivateKey'{}} | {psk, binary()} | {dhe_psk, binary(), binary()} | {srp, {binary(), binary()}, #srp_user{}, {HashAlgo::atom(), SignAlgo::atom()}, - binary(), binary(), private_key()}) -> + binary(), binary(), public_key:private_key()}) -> #client_key_exchange{} | #server_key_exchange{}. %% diff --git a/lib/ssl/src/ssl_internal.hrl b/lib/ssl/src/ssl_internal.hrl index 0186f9fca2cc..959ff213d418 100644 --- a/lib/ssl/src/ssl_internal.hrl +++ b/lib/ssl/src/ssl_internal.hrl @@ -35,7 +35,6 @@ -type certdb_ref() :: reference(). -type db_handle() :: term(). -type der_cert() :: binary(). --type private_key() :: #'RSAPrivateKey'{} | #'DSAPrivateKey'{} | #'ECPrivateKey'{}. -type issuer() :: tuple(). -type serialnumber() :: integer(). -type cert_key() :: {reference(), integer(), issuer()}. From 2de48af431824e9a8dc26a4cb14aeba7bfe0c943 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Thu, 12 Dec 2013 13:02:30 +0100 Subject: [PATCH 3/4] Consistently format public_key(3) When documenting public_key/0 and private_key/0, I noticed the inconsistent state of formatting in public_key(3)'s Data Types section. This should be fixed for consistency and readability. --- lib/public_key/doc/src/public_key.xml | 43 ++++++++++++++------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/lib/public_key/doc/src/public_key.xml b/lib/public_key/doc/src/public_key.xml index 613fbd2f16c4..a648c8ca8f70 100644 --- a/lib/public_key/doc/src/public_key.xml +++ b/lib/public_key/doc/src/public_key.xml @@ -71,7 +71,7 @@

Use the following include directive to get access to the records and constant macros described here and in the User's Guide.

- -include_lib("public_key/include/public_key.hrl"). + -include_lib("public_key/include/public_key.hrl").

Data Types

@@ -84,46 +84,49 @@

der_encoded() = binary()

pki_asn1_type() = 'Certificate' | 'RSAPrivateKey'| 'RSAPublicKey' | - 'DSAPrivateKey' | 'DSAPublicKey' | 'DHParameter' | 'SubjectPublicKeyInfo' | - 'PrivateKeyInfo' | 'CertificationRequest' | 'ECPrivateKey'| - 'EcpkParameters'

+ 'DSAPrivateKey' | 'DSAPublicKey' | 'DHParameter' | + 'SubjectPublicKeyInfo' | 'PrivateKeyInfo' | + 'CertificationRequest' | 'ECPrivateKey' | 'EcpkParameters'

pem_entry () = {pki_asn1_type(), binary(), %% DER or encrypted DER - not_encrypted | cipher_info()}

+ not_encrypted | cipher_info()}

-

cipher_info() = {"RC2-CBC | "DES-CBC" | "DES-EDE3-CBC", crypto:rand_bytes(8)} | - 'PBES2-params'}

+

cipher_info() = {"RC2-CBC | "DES-CBC" | "DES-EDE3-CBC", + crypto:rand_bytes(8)} | 'PBES2-params'}

public_key() = rsa_public_key() | dsa_public_key() | ec_public_key()

private_key() = rsa_public_key() | dsa_public_key() | ec_public_key()

rsa_public_key() = #'RSAPublicKey'{}

-

rsa_private_key() = #'RSAPrivateKey'{}

+

rsa_private_key() = #'RSAPrivateKey'{}

-

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

+

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

dsa_private_key() = #'DSAPrivateKey'{}

-

ec_public_key() = {#'ECPoint'{}, #'EcpkParameters'{} | {namedCurve, oid()}}

+

ec_public_key() = {#'ECPoint'{}, #'EcpkParameters'{} | + {namedCurve, oid()}}

ec_private_key() = #'ECPrivateKey'{}

-

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' | 'sha224' | 'sha256' | 'sha384' | 'sha512'

+

rsa_digest_type() = 'md5' | 'sha' | 'sha224' | 'sha256' | 'sha384' | + 'sha512'

-

dss_digest_type() = 'sha'

+

dss_digest_type() = 'sha'

-

ecdsa_digest_type() = 'sha'| 'sha224' | 'sha256' | 'sha384' | 'sha512'

+

ecdsa_digest_type() = 'sha'| 'sha224' | 'sha256' | 'sha384' | 'sha512'

-

crl_reason() = unspecified | keyCompromise | cACompromise | affiliationChanged | superseded | cessationOfOperation | certificateHold | privilegeWithdrawn | aACompromise -

+

crl_reason() = unspecified | keyCompromise | cACompromise | + affiliationChanged | superseded | cessationOfOperation | + certificateHold | privilegeWithdrawn | aACompromise

-

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

+

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

From d367b51f235fbc309e7eaf3b19ff2e66317593ae Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Thu, 12 Dec 2013 13:07:49 +0100 Subject: [PATCH 4/4] Fix incorrect type reference (inet:ipaddress() -> inet:ip_address()) --- lib/ssl/src/ssl_connection.hrl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ssl/src/ssl_connection.hrl b/lib/ssl/src/ssl_connection.hrl index 27489ca3254d..adb2e1debe37 100644 --- a/lib/ssl/src/ssl_connection.hrl +++ b/lib/ssl/src/ssl_connection.hrl @@ -41,7 +41,7 @@ data_tag :: atom(), % ex tcp. close_tag :: atom(), % ex tcp_closed error_tag :: atom(), % ex tcp_error - host :: string() | inet:ipaddress(), + host :: string() | inet:ip_address(), port :: integer(), socket :: port(), ssl_options :: #ssl_options{},