Topic: Intro to PKCS #3: Diffie-Hellman Key Agreement Standard

A while back, we started a series on the PKCS standards.  Our first post was about PKCS #1, the RSA Cryptography Standard.  This is the second post in the PKCS standards series, introducing PKCS #3 - the Diffie-Hellman Key Agreement Standard.

PKCS #3 is the Diffie-Hellman Key Agreement Standard and is currently defined by version 1.4 of the specification, located here: http://www.rsa.com/rsalabs/node.asp?id=2126.  It defines a standard enabling two parties to agree on a secret key known only to them (without having prior arrangements).  This is done in such a way that even if an eavesdropper is listening to the communication channel on which the key agreement took place, the eavesdropper will not be able to obtain the secret key.  After the secret key has been agreed upon by the two involved parties, it may be used in a subsequent operation - such as encrypting further communications between the two parties.

The specification itself defines standards for parameter generation, Phase 1 and 2 of the key agreement, and the object identifier to be used.

A. Parameter Generation

As stated in the specification, “a central authority shall generate Diffie-Hellman parameters, and the two phases of key agreement shall be performed with these parameters.”  This central authority will generate several parameters including an odd prime (p) and an integer (g), where the base satisfies 0 < g < p.  It may also optionally select an integer (l) which is the private-value length in bits and which satisfies 2^(l-1) <= p.

B. Phase 1

This section of the specification describes the first (of two) phases of the Diffie-Hellman key agreement and contains three steps, namely:

-private-value generation
-exponentiation
-integer-to-octet-string conversion

As stated by the specification, “the input to the first phase shall be the Diffie-Hellman parameters.  The output from the first phase shall be an octet string PV, the public value; and an integer x, the private value.”  Each party of the key agreement will perform Phase 1 independently of the other party.

C. Phase 2

This section of the specification describes the second phase of the Diffie-Hellman key agreement and contains three steps as well, namely:

-octet-string-to-integer conversion
-exponentiation
-integer-to-octet-string conversion

As stated by the specification, “the input to the second phase shall be the Diffie-Hellman parameters; an octet string PV’, the other entity’s public value; and the private value x.  The output from the second phase shall be an octet string SK, the agreed-upon secret key.”  As the first step, this step is performed by each party independently as well (but after they have exchanged public values from the Phase 1).

D. Object Identifier

The last item defined in PKCS #3 are two object identifiers to be used with Diffie-Hellman key agreement, pkcs-3 and dhKeyAgreement.  The pkcs-3 OID identifies Diffie-Hellman key agreement and is specified as:

pkcs-3 OBJECT IDENTIFIER ::=  { iso(1)  member-body(2)  US(840)  rsadsi(113549)  pkcs(1)  3 }

The second OID, dhKeyAgreement, identifies the PKCS #3 key agreement method.

To learn more about PKCS #3, you can look through the specification, here:

http://www.rsa.com/rsalabs/node.asp?id=2126

To learn more about the CyaSSL embedded SSL library, you can download a free GPLv2-licensed copy from the yaSSL download page, http://yassl.com/yaSSL/download/downloadForm.php, or look through the CyaSSL Manual, http://www.yassl.com/yaSSL/Docs-cyassl-manual-toc.html.  If you have any additional questions, please contact us .