Diffie-Hellman shared secret computation in discrete logarithm (DL) domain. More...
Functions | |
C4eArchSize | c4e_dlc_dh_std (C4eDlcDomain *C4E_RESTRICT dom, C4E_CONST C4eElement *C4E_RESTRICT d, C4eArchDigit tmp[C4E_RESTRICT], C4eElement *C4E_RESTRICT e, C4eArchUint8 *C4E_RESTRICT secret) |
"Standard" Diffie-Hellman shared secret computation in DL domain (according to PKCS #3, IEEE Std 1363, ANSI X9.42, ISO 11770-3, NIST SP800-56A, RFC 2631, etc). | |
C4eArchSize | c4e_dlc_dh_tls (C4eDlcDomain *C4E_RESTRICT dom, C4E_CONST C4eElement *C4E_RESTRICT d, C4eArchDigit tmp[C4E_RESTRICT], C4eElement *C4E_RESTRICT e, C4eArchUint8 *C4E_RESTRICT secret) |
Diffie-Hellman shared secret computation according to SSL/TLS. |
Diffie-Hellman shared secret computation in discrete logarithm (DL) domain.
C4eArchSize c4e_dlc_dh_std | ( | C4eDlcDomain *C4E_RESTRICT | dom, | |
C4E_CONST C4eElement *C4E_RESTRICT | d, | |||
C4eArchDigit | tmp[C4E_RESTRICT], | |||
C4eElement *C4E_RESTRICT | e, | |||
C4eArchUint8 *C4E_RESTRICT | secret | |||
) |
"Standard" Diffie-Hellman shared secret computation in DL domain (according to PKCS #3, IEEE Std 1363, ANSI X9.42, ISO 11770-3, NIST SP800-56A, RFC 2631, etc).
This function performes an exponentiation of e
by the private exponent d
modulo dom->m
, resulting in a shared secret .
It simply calculates the shared secret, which is the starting point for deriving a shared (symmetric) session key.
dom->m.val
is temporary modified - so it must be writable. After function return it holds the same values as at function entry.dom
must be assured by the caller, either implicit or by using function c4e_dlc_domchk(). d
must be assured by the caller, either implicit or by using function c4e_dlc_keychk_prv(). e
must be assured by the caller, for example by using function c4e_dlc_keychk_pub(). e
is (dom->m.val.size
+ 1). tmp
[], using macro C4E_DLC_TMP_NUM() in conjunction with temp. space qualifier C4E_DLC_DH_TMPID_STD.[in] | dom | Pointer to DLC domain parameters. |
[in] | d | Pointer to DH private key. |
tmp | Array of temporary space elements (see preconditions for details on size). | |
[in] | e | Other party DH public key (from DL domain). Notice that public key e is destroyed. |
[out] | secret | Shared secret of both parties, in network byte order. |
secret
, which is dom->m.len
on success. Any other value should be interpreted as error.C4eArchSize c4e_dlc_dh_tls | ( | C4eDlcDomain *C4E_RESTRICT | dom, | |
C4E_CONST C4eElement *C4E_RESTRICT | d, | |||
C4eArchDigit | tmp[C4E_RESTRICT], | |||
C4eElement *C4E_RESTRICT | e, | |||
C4eArchUint8 *C4E_RESTRICT | secret | |||
) |
Diffie-Hellman shared secret computation according to SSL/TLS.
It simply calculates the shared secret (with leading zeros stripped), which is the starting point for deriving a shared (symmetric) session key.
Notice that this DH implementation (also the implementation of OpenSSL) is compliant with the SSL/TLS requirement from RFC 5246, section 8.1.2, that leading zeroes on the shared secret must be stripped. For example PKCS #3 does not specify such a requirement. Standards like ANSI X9.42 (RFC 2631) and IEEE Std 1363 apply a hash function combined with some other stuff after computing the shared secret - so it makes no sense for these standards to strip leading zeros.
dom->m.val
is temporary modified - so it must be writable. After function return it holds the same values as at function entry.dom
must be assured by the caller, either implicit or by using function c4e_dlc_domchk(). d
must be assured by the caller, either implicit or by using function c4e_dlc_keychk_prv(). e
is (dom->m.val.size
+ 1). tmp
[], using macro C4E_DLC_TMP_NUM() in conjunction with temp. space qualifier C4E_DLC_DH_TMPID_TLS.[in] | dom | Pointer to DLC domain parameters. |
[in] | d | Pointer to DH private key. |
tmp | Array of temporary space elements (see preconditions for details on size). | |
[in] | e | Other party DH public key (from DL domain). Notice that public key e is destroyed. |
[out] | secret | Shared secret of both parties, in network byte order (leading zeros stripped). |
secret
(less/equal than dom->m.len
), 0 on error.