RFC 5915

Elliptic Curve Private Key Structure

๐Ÿ“… published June 2010, from ietf

Elliptic Curve Private Key Structure ๐ŸŽ€โœจ

RFC 5915, published by the IETF in June 2010 ๐ŸŒธ It's an Informational doc (not a Standards Track spec), with ISSN 2070-1721. The authors are S. Turner (IECA) and D. Brown (Certicom). The header doesn't list anything it obsoletes or updates, so it's a standalone doc ๐Ÿ’…


Abstract โœจ

okay so this doc is all about how to write down an Elliptic Curve (EC) private key in a standard way ๐Ÿ” The rules and meanings are based on what the Standards for Efficient Cryptography Group (SECG) already defined. We're not inventing a new thing here, just making sure everyone's on the same page ๐Ÿซถ

Status of This Memo ๐Ÿ“œ

tl;dr: this is not an Internet Standards Track spec. It's published just for info ๐Ÿฆ‹

It's an IETF product, so it reflects consensus from the IETF community. It got public review and was approved by the Internet Engineering Steering Group (IESG). Not every IESG-approved doc is up for any level of Internet Standard, though. See Section 2 of RFC 5741 for the deets ๐Ÿ’…

Want the latest status, errata, or a place to send feedback? Head to http://www.rfc-editor.org/info/rfc5915 ๐Ÿ’–

Copyright (c) 2010 IETF Trust and the persons identified as the document authors. All rights reserved ๐ŸŒˆ

This doc falls under BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) as they were on the publication date. Read those carefully, bestie, because they spell out your rights and restrictions ๐Ÿงพ Any Code Components pulled out of this doc have to include the Simplified BSD License text (see Section 4.e of the Trust Legal Provisions), and they come with no warranty, as the Simplified BSD License describes ๐Ÿซถ

1. Introduction ๐Ÿงš

So this doc gives you a syntax and semantics for EC private key information ๐Ÿ”‘ That info has a private key and parameters, and it may also include the matching public key ๐Ÿ’œ The rules here come from SECG's similar stuff [SECG1] ๐Ÿ“

Most PKIs require local key generation, which is the main vibe. A few PKIs also do centralized key generation, where a Certification Authority makes the public-private key pair for you ๐Ÿ‘‘ This structure lets whoever generated the keys hand over the key pair and its domain parameters ๐ŸŽ

This syntax is especially useful when you're sending EC private keys around in PrivateKeyInfo, which is defined in PKCS #8 [RFC5208] ๐Ÿฆ‹ To distribute an EC private key with PKCS#8 [RFC5208], you include:

  • a) id-ecPublicKey, id-ecDH, or id-ecMQV (from [RFC5480]), with the namedCurve as the parameters in the privateKeyAlgorithm field; and
  • b) ECPrivateKey in the PrivateKey field, which is an OCTET STRING.

And if an EC public key is part of the distributed PrivateKeyInfo, the publicKey field inside ECPrivateKey is the one that gets used ๐Ÿซถ

2. Terminology ๐Ÿ“–

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119] ๐Ÿ’…

3. Elliptic Curve Private Key Format ๐Ÿ”

Here's the syntax for an EC private key โœจ Mathematically, an EC private key is an unsigned integer. For representation, though, EC private key information SHALL have the ASN.1 type ECPrivateKey:

ECPrivateKey ::= SEQUENCE {
  version        INTEGER { ecPrivkeyVer1(1) } (ecPrivkeyVer1),
  privateKey     OCTET STRING,
  parameters [0] ECParameters {{ NamedCurve }} OPTIONAL,
  publicKey  [1] BIT STRING OPTIONAL
}

Here's what each field of ECPrivateKey means ๐Ÿ’–

  • version is the syntax version number of the EC private key structure ๐ŸŽ€ For this version of the doc, it SHALL be set to ecPrivkeyVer1, which is an INTEGER with a value of one (1) ๐Ÿ“
  • privateKey is the private key itself ๐Ÿ—๏ธ It's an octet string of length ceiling (log2(n)/8) (where n is the order of the curve), made from the unsigned integer using the Integer-to-Octet-String-Primitive (I2OSP) defined in [RFC3447] ๐Ÿงš
  • parameters gives the EC domain parameters tied to the private key ๐Ÿ‘‘ The ECParameters type is discussed in [RFC5480]. As [RFC5480] says, only the namedCurve CHOICE is allowed ๐Ÿ™ˆ namedCurve is an object identifier that fully pins down the values for one particular set of EC domain parameters. Even though the ASN.1 marks parameters as OPTIONAL, implementations that conform to this doc MUST always include the parameters field ๐Ÿšจ
  • publicKey holds the EC public key that goes with the private key in question ๐Ÿ’œ Its format is specified in Section 2.2 of [RFC5480] ๐ŸŒธ Even though the ASN.1 says publicKey is OPTIONAL, implementations that conform to this doc SHOULD always include the publicKey field โœจ It can be left out when the public key was distributed some other way, which is outside this doc's scope ๐Ÿฆ‹ Since you can always recompute the public key from the private key and the parameters, this field is just a convenience for the consumer ๐Ÿซถ

4. Other Considerations ๐ŸŒˆ

When you're generating a transfer encoding, generators SHOULD use Distinguished Encoding Rules (DER) [X.690], and receivers SHOULD be ready to handle Basic Encoding Rules (BER) [X.690] as well as DER [X.690] ๐Ÿ’…

Section 1 described a format for transporting EC private keys (aka converting ECPrivateKey to PrivateKeyInfo [PKCS#8]). BUT, and this is the fun part ๐Ÿ™ˆ the same format can also be used for local storage!

Storing an unencrypted ECPrivateKey object locally is out of scope for this doc ๐Ÿ”’ Still, one super popular format uses the .pem file extension ๐Ÿ“ It's the PEM encoding, which is Base64 (see Section 4 of [RFC4648]) applied to the DER-encoded ECPrivateKey object, sandwiched between these two lines:

-----BEGIN EC PRIVATE KEY-----
-----END EC PRIVATE KEY-----

Another local storage format uses the .der file extension ๐Ÿง In that case, the file is a DER [X.690] encoding of the ECPrivateKey object ๐Ÿ’œ

Storing an encrypted ECPrivateKey object locally is also out of scope for this doc ๐Ÿ™… Still, ECPrivateKey should be the format for the plaintext key being encrypted โœจ DER-encoding the ECPrivateKey [X.690] promotes interoperability if the key gets encrypted for transport to another party ๐Ÿซถ PEM-encoding the DER-encoded ECPrivateKey is common. The Proc-Type: and DEK-INFO: fields [RFC1421] go first, followed by the DER-encoded ECPrivateKey, all sandwiched between:

-----BEGIN EC PRIVATE KEY-----
-----END EC PRIVATE KEY-----

Appendix B. Differences with SECG1 ๐ŸŽ€

okay so bestie, this appendix is basically the "how is this different from SECG1" tea โ˜• and it's giving very organised list energy ๐Ÿ’… Here's the lowdown on what's changed:

  1. This document uses the I2OSP routine defined in [RFC3447] while SECG1 defines its own routine. โœจ Like, two different routines, but they literally give the same output ๐Ÿซถ
  2. SECG1 constrains its parameters (i.e., the curves) to SECGCurveNames. ๐ŸŒธ This document constrains the parameters to NamedCurve from [RFC5480]. ๐Ÿ’– Different name lists, same vibe of "pick from the approved curves" ๐Ÿงš
  3. This document REQUIRES parameters be present ๐Ÿ”ฅ while SECG1 does not. Like, the parameters are not optional here, bestie ๐Ÿ˜ญ
  4. This document specifies requirements for encoding rules ๐Ÿฆ‹ while SECG1 did not. So this one actually spells out how to encode things, no cap ๐Ÿ’œ

Acknowledgements ๐ŸŒˆ

the authors are SO grateful to Simon Blake-Wilson and John O. Goyo for their work on defining the structure in [SECG1] ๐Ÿ™ˆ They also want to thank Pasi Eronen, Alfred Hoenes, Joel Jaegglie, Avshalom Houri, Russ Housley, Jim Schaad, and Carl Wallace for their comments. Iconic squad ๐Ÿ‘‘โœจ


Authors' Addresses ๐Ÿ“ฎ

Sean Turner IECA, Inc. 3057 Nutley Street, Suite 106 Fairfax, VA 22031 USA

EMail: turners@ieca.com

Daniel R. L. Brown Certicom Corp 5520 Explorer Drive #400 Mississauga, ON L4W 5L1 Canada

EMail: dbrown@certicom.com ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from