idnits 2.17.1 draft-irtf-cfrg-curves-10.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (October 3, 2015) is 3126 days in the past. Is this intentional? Checking references for intended status: Informational ---------------------------------------------------------------------------- -- Looks like a reference, but probably isn't: '0' on line 542 -- Looks like a reference, but probably isn't: '1' on line 278 -- Looks like a reference, but probably isn't: '2' on line 278 -- Looks like a reference, but probably isn't: '31' on line 542 Summary: 0 errors (**), 0 flaws (~~), 1 warning (==), 5 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 CFRG A. Langley 3 Internet-Draft Google 4 Intended status: Informational M. Hamburg 5 Expires: April 5, 2016 Rambus Cryptography Research 6 S. Turner 7 IECA, Inc. 8 October 3, 2015 10 Elliptic Curves for Security 11 draft-irtf-cfrg-curves-10 13 Abstract 15 This memo specifies two elliptic curves over prime fields that offer 16 high practical security in cryptographic applications, including 17 Transport Layer Security (TLS). These curves are intended to operate 18 at the ~128-bit and ~224-bit security level, respectively, and are 19 generated deterministically based on a list of required properties. 21 Status of This Memo 23 This Internet-Draft is submitted in full conformance with the 24 provisions of BCP 78 and BCP 79. 26 Internet-Drafts are working documents of the Internet Engineering 27 Task Force (IETF). Note that other groups may also distribute 28 working documents as Internet-Drafts. The list of current Internet- 29 Drafts is at http://datatracker.ietf.org/drafts/current/. 31 Internet-Drafts are draft documents valid for a maximum of six months 32 and may be updated, replaced, or obsoleted by other documents at any 33 time. It is inappropriate to use Internet-Drafts as reference 34 material or to cite them other than as "work in progress." 36 This Internet-Draft will expire on April 5, 2016. 38 Copyright Notice 40 Copyright (c) 2015 IETF Trust and the persons identified as the 41 document authors. All rights reserved. 43 This document is subject to BCP 78 and the IETF Trust's Legal 44 Provisions Relating to IETF Documents 45 (http://trustee.ietf.org/license-info) in effect on the date of 46 publication of this document. Please review these documents 47 carefully, as they describe your rights and restrictions with respect 48 to this document. Code Components extracted from this document must 49 include Simplified BSD License text as described in Section 4.e of 50 the Trust Legal Provisions and are provided without warranty as 51 described in the Simplified BSD License. 53 Table of Contents 55 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 56 2. Requirements Language . . . . . . . . . . . . . . . . . . . . 3 57 3. Notation . . . . . . . . . . . . . . . . . . . . . . . . . . 3 58 4. Recommended Curves . . . . . . . . . . . . . . . . . . . . . 3 59 4.1. Curve25519 . . . . . . . . . . . . . . . . . . . . . . . 3 60 4.2. Curve448 . . . . . . . . . . . . . . . . . . . . . . . . 4 61 5. The X25519 and X448 functions . . . . . . . . . . . . . . . . 6 62 5.1. Side-channel considerations . . . . . . . . . . . . . . . 10 63 5.2. Test vectors . . . . . . . . . . . . . . . . . . . . . . 10 64 6. Diffie-Hellman . . . . . . . . . . . . . . . . . . . . . . . 12 65 6.1. Curve25519 . . . . . . . . . . . . . . . . . . . . . . . 13 66 6.2. Curve448 . . . . . . . . . . . . . . . . . . . . . . . . 13 67 7. Security Considerations . . . . . . . . . . . . . . . . . . . 14 68 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 15 69 9. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 15 70 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 15 71 10.1. Normative References . . . . . . . . . . . . . . . . . . 15 72 10.2. Informative References . . . . . . . . . . . . . . . . . 15 73 Appendix A. Deterministic Generation . . . . . . . . . . . . . . 17 74 A.1. p = 1 mod 4 . . . . . . . . . . . . . . . . . . . . . . . 17 75 A.2. p = 3 mod 4 . . . . . . . . . . . . . . . . . . . . . . . 18 76 A.3. Base points . . . . . . . . . . . . . . . . . . . . . . . 19 77 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 19 79 1. Introduction 81 Since the initial standardization of elliptic curve cryptography (ECC 82 [RFC6090]) in [SEC1] there has been significant progress related to 83 both efficiency and security of curves and implementations. Notable 84 examples are algorithms protected against certain side-channel 85 attacks, various 'special' prime shapes that allow faster modular 86 arithmetic, and a larger set of curve models from which to choose. 87 There is also concern in the community regarding the generation and 88 potential weaknesses of the curves defined by NIST [NIST]. 90 This memo specifies two elliptic curves ("curve25519" and "curve448") 91 that lend themselves to constant-time implementation and an 92 exception-free scalar multiplication that is resistant to a wide 93 range of side-channel attacks, including timing and cache attacks. 94 They are Montgomery curves (where y^2 = x^3 + Ax^2 + x) and thus have 95 birationally equivalent Edwards versions. Edwards curves support the 96 fastest (currently known) complete formulas for the elliptic-curve 97 group operations, specifically the Edwards curve x^2 + y^2 = 1 + 98 dx^2y^2 for primes p when p = 3 mod 4, and the twisted Edwards curve 99 -x^2 + y^2 = 1 + dx^2y^2 when p = 1 mod 4. The maps to/from the 100 Montgomery curves to their (twisted) Edwards equivalents are also 101 given. 103 This memo also specifies how these curves can be used with the 104 Diffie-Hellman protocol for key agreement. 106 2. Requirements Language 108 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 109 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 110 document are to be interpreted as described in RFC 2119 [RFC2119]. 112 3. Notation 114 Throughout this document, the following notation is used: 116 p Denotes the prime number defining the underlying field. 118 GF(p) The finite field with p elements. 120 A An element in the finite field GF(p), not equal to -2 or 2. 122 d A non-zero element in the finite field GF(p), not equal to 1, in 123 the case of an Edwards curve, or not equal to -1, in the case of a 124 twisted Edwards curve. 126 P A generator point defined over GF(p) of prime order. 128 X(P) The x-coordinate of the elliptic curve point P on a (twisted) 129 Edwards curve. 131 Y(P) The y-coordinate of the elliptic curve point P on a (twisted) 132 Edwards curve. 134 u, v Coordinates on a Montgomery curve. 136 x, y Coordinates on a (twisted) Edwards curve. 138 4. Recommended Curves 140 4.1. Curve25519 142 For the ~128-bit security level, the prime 2^255-19 is recommended 143 for performance on a wide-range of architectures. Few primes of the 144 form 2^c-s with s small exist between 2^250 and 2^521, and other 145 choices of coefficient are not as competitive in performance. This 146 prime is congruent to 1 mod 4 and the derivation procedure in 147 Appendix A results in the following Montgomery curve v^2 = u^3 + 148 A*u^2 + u, called "curve25519": 150 p 2^255-19 152 A 486662 154 order 2^252 + 0x14def9dea2f79cd65812631a5cf5d3ed 156 cofactor 8 158 The base point is u = 9, v = 1478161944758954479102059356840998688726 159 4606134616475288964881837755586237401. 161 This curve is birationally equivalent to a twisted Edwards curve -x^2 162 + y^2 = 1 + d*x^2*y^2, called "edwards25519", where: 164 p 2^255-19 166 d 370957059346694393431380835087545651895421138798432190163887855330 167 85940283555 169 order 2^252 + 0x14def9dea2f79cd65812631a5cf5d3ed 171 cofactor 8 173 X(P) 151122213495354007725011514095885315114540126930418572060461132 174 83949847762202 176 Y(P) 463168356949264781694283940034751631413079938662562256157830336 177 03165251855960 179 The birational maps are: 181 (u, v) = ((1+y)/(1-y), sqrt(-486664)*u/x) 182 (x, y) = (sqrt(-486664)*u/v, (u-1)/(u+1)) 184 The Montgomery curve defined here is equal to the one defined in 185 [curve25519] and the equivalent twisted Edwards curve is equal to the 186 one defined in [ed25519]. 188 4.2. Curve448 190 For the ~224-bit security level, the prime 2^448-2^224-1 is 191 recommended for performance on a wide-range of architectures. This 192 prime is congruent to 3 mod 4 and the derivation procedure in 193 Appendix A results in the following Montgomery curve, called 194 "curve448": 196 p 2^448-2^224-1 198 A 156326 200 order 2^446 - 201 0x8335dc163bb124b65129c96fde933d8d723a70aadc873d6d54a7bb0d 203 cofactor 4 205 The base point is u = 5, v = 3552939267855681752641275020637833348089 206 763993877142718318808984351690887869674100029326737658645509101427741 207 47268105838985595290606362. 209 This curve is birationally equivalent to the Edwards curve x^2 + y^2 210 = 1 + d*x^2*y^2 where: 212 p 2^448-2^224-1 214 d 611975850744529176160423220965553317543219696871016626328968936415 215 087860042636474891785599283666020414768678979989378147065462815545 216 017 218 order 2^446 - 219 0x8335dc163bb124b65129c96fde933d8d723a70aadc873d6d54a7bb0d 221 cofactor 4 223 X(P) 345397493039729516374008604150537410266655260075183290216406970 224 281645695073672344430481787759340633221708391583424041788924124567 225 700732 227 Y(P) 363419362147803445274661903944002267176820680343659030140745099 228 590306164083365386343198191849338272965044442230921818680526749009 229 182718 231 The birational maps are: 233 (u, v) = ((y-1)/(y+1), sqrt(156324)*u/x) 234 (x, y) = (sqrt(156324)*u/v, (1+u)/(1-u)) 236 Both of those curves are also 4-isogenous to the following Edwards 237 curve x^2 + y^2 = 1 + d*x^2*y^2, called "edwards448", where: 239 p 2^448-2^224-1 240 d -39081 242 order 2^446 - 243 0x8335dc163bb124b65129c96fde933d8d723a70aadc873d6d54a7bb0d 245 cofactor 4 247 X(P) 224580040295924300187604334099896036246789641632564134246125461 248 686950415467406032909029192869357953282578032075146446173674602635 249 247710 251 Y(P) 298819210078481492676017930443930673437544040154080242095928241 252 372331506189835876003536878655418784733982303233503462500531545062 253 832660 255 The 4-isogeny maps between the Montgomery curve and this Edwards 256 curve are: 258 (u, v) = (y^2/x^2, (2 - x^2 - y^2)*y/x^3) 259 (x, y) = (4*v*(u^2 - 1)/(u^4 - 2*u^2 + 4*v^2 + 1), 260 -(u^5 - 2*u^3 - 4*u*v^2 + u)/ 261 (u^5 - 2*u^2*v^2 - 2*u^3 - 2*v^2 + u)) 263 The curve edwards448 defined here is also called "Goldilocks" and is 264 equal to the one defined in [goldilocks]. 266 5. The X25519 and X448 functions 268 The "X25519" and "X448" functions perform scalar multiplication on 269 the Montgomery form of the above curves. (This is used when 270 implementing Diffie-Hellman.) The functions take a scalar and a 271 u-coordinate as inputs and produce a u-coordinate as output. 272 Although the functions work internally with integers, the inputs and 273 outputs are 32-byte strings (for X25519) or 56-byte strings (for 274 X448) and this specification defines their encoding. 276 The u-coordinates are elements of the underlying field GF(2^255-19) 277 or GF(2^448-2^224-1) and are encoded as an array of bytes, u, in 278 little-endian order such that u[0] + 256*u[1] + 256^2*u[2] + ... + 279 256^(n-1)*u[n-1] is congruent to the value modulo p and u[n-1] is 280 minimal. When receiving such an array, implementations of X25519 281 (but not X448) MUST mask the most-significant bit in the final byte. 282 This is done to preserve compatibility with point formats which 283 reserve the sign bit for use in other protocols and to increase 284 resistance to implementation fingerprinting. 286 Implementations MUST accept non-canonical values and process them as 287 if they had been reduced modulo the field prime. The non-canonical 288 values are 2^255-19 through 2^255-1 for X25519 and 2^448-2^224-1 289 through 2^448-1 for X448. 291 The following functions implement this in Python, although the Python 292 code is not intended to be performant nor side-channel free. Here 293 the "bits" parameter should be set to 255 for X25519 and 448 for 294 X448: 296 297 def decodeLittleEndian(b, bits): 298 return sum([b[i] << 8*i for i in range((bits+7)/8)]) 300 def decodeUCoordinate(u, bits): 301 u_list = [ord(b) for b in u] 302 # Ignore any unused bits. 303 if bits % 8: 304 u_list[-1] &= (1<<(bits%8))-1 305 return decodeLittleEndian(u_list, bits) 307 def encodeUCoordinate(u, bits): 308 u = u % p 309 return ''.join([chr((u >> 8*i) & 0xff) 310 for i in range((bits+7)/8)]) 311 313 Scalars are assumed to be randomly generated bytes. For X25519, in 314 order to decode 32 random bytes as an integer scalar, set the three 315 least significant bits of the first byte and the most significant bit 316 of the last to zero, set the second most significant bit of the last 317 byte to 1 and, finally, decode as little-endian. This means that 318 resulting integer is of the form 2^254 + 8 * {0, 1, ..., 2^(251) - 319 1}. Likewise, for X448, set the two least significant bits of the 320 first byte to 0, and the most significant bit of the last byte to 1. 321 This means that the resulting integer is of the form 2^447 + 4 * {0, 322 1, ..., 2^(445) - 1}. 324 325 def decodeScalar25519(k): 326 k_list = [ord(b) for b in k] 327 k_list[0] &= 248 328 k_list[31] &= 127 329 k_list[31] |= 64 330 return decodeLittleEndian(k_list, 255) 332 def decodeScalar448(k): 333 k_list = [ord(b) for b in k] 334 k_list[0] &= 252 335 k_list[55] |= 128 336 return decodeLittleEndian(k_list, 448) 337 339 To implement the X25519(k, u) and X448(k, u) functions (where k is 340 the scalar and u is the u-coordinate) first decode k and u and then 341 perform the following procedure, which is taken from [curve25519] and 342 based on formulas from [montgomery]. All calculations are performed 343 in GF(p), i.e., they are performed modulo p. The constant a24 is 344 (486662 - 2) / 4 = 121665 for curve25519/X25519 and (156326 - 2) / 4 345 = 39081 for curve448/X448. 347 x_1 = u 348 x_2 = 1 349 z_2 = 0 350 x_3 = u 351 z_3 = 1 352 swap = 0 354 For t = bits-1 down to 0: 355 k_t = (k >> t) & 1 356 swap ^= k_t 357 // Conditional swap; see text below. 358 (x_2, x_3) = cswap(swap, x_2, x_3) 359 (z_2, z_3) = cswap(swap, z_2, z_3) 360 swap = k_t 362 A = x_2 + z_2 363 AA = A^2 364 B = x_2 - z_2 365 BB = B^2 366 E = AA - BB 367 C = x_3 + z_3 368 D = x_3 - z_3 369 DA = D * A 370 CB = C * B 371 x_3 = (DA + CB)^2 372 z_3 = x_1 * (DA - CB)^2 373 x_2 = AA * BB 374 z_2 = E * (AA + a24 * E) 376 // Conditional swap; see text below. 377 (x_2, x_3) = cswap(swap, x_2, x_3) 378 (z_2, z_3) = cswap(swap, z_2, z_3) 379 Return x_2 * (z_2^(p - 2)) 381 (Note that these formulas are slightly different from Montgomery's 382 original paper. Implementations are free to use any correct 383 formulas.) 385 Finally, encode the resulting value as 32 or 56 bytes in little- 386 endian order. For X25519, the unused, most-significant bit MUST be 387 zero. 389 The cswap function SHOULD be implemented in constant time (i.e. 390 independent of the swap argument). For example, this can be done as 391 follows: 393 cswap(swap, x_2, x_3): 394 dummy = mask(swap) AND (x_2 XOR x_3) 395 x_2 = x_2 XOR dummy 396 x_3 = x_3 XOR dummy 397 Return (x_2, x_3) 399 Where mask(swap) is the all-1 or all-0 word of the same length as x_2 400 and x_3, computed, e.g., as mask(swap) = 0 - swap. 402 5.1. Side-channel considerations 404 X25519 and X448 are designed so that fast, constant-time 405 implementations are easier to produce. The procedure above ensures 406 that the same sequence of field operations is performed for all 407 values of the secret key, thus eliminating a common source of side- 408 channel leakage. However, this alone does not prevent all side- 409 channels by itself. It is important that the pattern of memory 410 accesses and jumps not depend on the values of any of the bits of k. 411 It is also important that the arithmetic used not leak information 412 about the integers modulo p, for example by having b*c be 413 distinguishable from c*c. On some architectures, even primitive 414 machine instructions, such as single-word division, can have variable 415 timing based on their inputs. 417 Side-channel attacks are an active research area that still sees 418 significant, new results. Implementors are advised to follow this 419 research closely. 421 5.2. Test vectors 423 Two types of tests are provided. The first is a pair of test vectors 424 for each function that consist of expected outputs for the given 425 inputs. The inputs are generally given as 64 or 112 hexadecimal 426 digits that need to be decoded as 32 or 56 binary bytes before 427 processing. 429 X25519: 431 Input scalar: 432 a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4 433 Input scalar as a number (base 10): 434 31029842492115040904895560451863089656 435 472772604678260265531221036453811406496 436 Input u-coordinate: 437 e6db6867583030db3594c1a424b15f7c726624ec26b3353b10a903a6d0ab1c4c 438 Input u-coordinate as a number: 439 34426434033919594451155107781188821651 440 316167215306631574996226621102155684838 442 Output u-coordinate: 443 c3da55379de9c6908e94ea4df28d084f32eccf03491c71f754b4075577a28552 445 Input scalar: 446 4b66e9d4d1b4673c5ad22691957d6af5c11b6421e0ea01d42ca4169e7918ba0d 447 Input scalar as a number (base 10): 448 35156891815674817266734212754503633747 449 128614016119564763269015315466259359304 450 Input u-coordinate: 451 e5210f12786811d3f4b7959d0538ae2c31dbe7106fc03c3efc4cd549c715a493 452 Input u-coordinate as a number: 453 88838573511839298940907593866106493194 454 17338800022198945255395922347792736741 455 Output u-coordinate: 456 95cbde9476e8907d7aade45cb4b873f88b595a68799fa152e6f8f7647aac7957 458 X448: 460 Input scalar: 461 3d262fddf9ec8e88495266fea19a34d28882acef045104d0d1aae121 462 700a779c984c24f8cdd78fbff44943eba368f54b29259a4f1c600ad3 463 Input scalar as a number (base 10): 464 599189175373896402783756016145213256157230856 465 085026129926891459468622403380588640249457727 466 683869421921443004045221642549886377526240828 467 Input u-coordinate: 468 06fce640fa3487bfda5f6cf2d5263f8aad88334cbd07437f020f08f9 469 814dc031ddbdc38c19c6da2583fa5429db94ada18aa7a7fb4ef8a086 470 Input u-coordinate as a number: 471 382239910814107330116229961234899377031416365 472 240571325148346555922438025162094455820962429 473 142971339584360034337310079791515452463053830 474 Output u-coordinate: 475 ce3e4ff95a60dc6697da1db1d85e6afbdf79b50a2412d7546d5f239f 476 e14fbaadeb445fc66a01b0779d98223961111e21766282f73dd96b6f 478 Input scalar: 479 203d494428b8399352665ddca42f9de8fef600908e0d461cb021f8c5 480 38345dd77c3e4806e25f46d3315c44e0a5b4371282dd2c8d5be3095f 481 Input scalar as a number (base 10): 482 633254335906970592779259481534862372382525155 483 252028961056404001332122152890562527156973881 484 968934311400345568203929409663925541994577184 485 Input u-coordinate: 486 0fbcc2f993cd56d3305b0b7d9e55d4c1a8fb5dbb52f8e9a1e9b6201b 487 165d015894e56c4d3570bee52fe205e28a78b91cdfbde71ce8d157db 488 Input u-coordinate as a number: 490 622761797758325444462922068431234180649590390 491 024811299761625153767228042600197997696167956 492 134770744996690267634159427999832340166786063 493 Output u-coordinate: 494 884a02576239ff7a2f2f63b2db6a9ff37047ac13568e1e30fe63c4a7 495 ad1b3ee3a5700df34321d62077e63633c575c1c954514e99da7c179d 497 The second type of test vector consists of the result of calling the 498 function in question a specified number of times. Initially, set k 499 and u to be the following values: 501 For X25519: 502 0900000000000000000000000000000000000000000000000000000000000000 503 For X448: 504 05000000000000000000000000000000000000000000000000000000 505 00000000000000000000000000000000000000000000000000000000 507 For each iteration, set k to be the result of calling the function 508 and u to be the old value of k. The final result is the value left 509 in k. 511 X25519: 513 After one iteration: 514 422c8e7a6227d7bca1350b3e2bb7279f7897b87bb6854b783c60e80311ae3079 515 After 1,000 iterations: 516 684cf59ba83309552800ef566f2f4d3c1c3887c49360e3875f2eb94d99532c51 517 After 1,000,000 iterations: 518 7c3911e0ab2586fd864497297e575e6f3bc601c0883c30df5f4dd2d24f665424 520 X448: 522 After one iteration: 523 3f482c8a9f19b01e6c46ee9711d9dc14fd4bf67af30765c2ae2b846a 524 4d23a8cd0db897086239492caf350b51f833868b9bc2b3bca9cf4113 525 After 1,000 iterations: 526 aa3b4749d55b9daf1e5b00288826c467274ce3ebbdd5c17b975e09d4 527 af6c67cf10d087202db88286e2b79fceea3ec353ef54faa26e219f38 528 After 1,000,000 iterations: 529 077f453681caca3693198420bbe515cae0002472519b3e67661a7e89 530 cab94695c8f4bcd66e61b9b9c946da8d524de3d69bd9d9d66b997e37 532 6. Diffie-Hellman 533 6.1. Curve25519 535 The X25519 function can be used in an elliptic-curve Diffie-Hellman 536 (ECDH) protocol as follows: 538 Alice generates 32 random bytes in f[0] to f[31] and transmits K_A = 539 X25519(f, 9) to Bob, where 9 is the u-coordinate of the base point 540 and is encoded as a byte with value 9, followed by 31 zero bytes. 542 Bob similarly generates 32 random bytes in g[0] to g[31] and computes 543 K_B = X25519(g, 9) and transmits it to Alice. 545 Using their generated values and the received input, Alice computes 546 X25519(f, K_B) and Bob computes X25519(g, K_A). 548 Both now share K = X25519(f, X25519(g, 9)) = X25519(g, X25519(f, 9)) 549 as a shared secret. Both MUST check, without leaking extra 550 information about the value of K, whether K is the all-zero value and 551 abort if so (see below). Alice and Bob can then use a key-derivation 552 function that includes K, K_A and K_B to derive a key. 554 The check for the all-zero value results from the fact that the 555 X25519 function produces that value if it operates on an input 556 corresponding to a point with order dividing the co-factor, h, of the 557 curve. This check is cheap and so MUST always be carried out. The 558 check may be performed by ORing all the bytes together and checking 559 whether the result is zero as this eliminates standard side-channels 560 in software implementations. 562 Test vector: 564 Alice's private key, f: 565 77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a 566 Alice's public key, X25519(f, 9): 567 8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a 568 Bob's private key, g: 569 5dab087e624a8a4b79e17f8b83800ee66f3bb1292618b6fd1c2f8b27ff88e0eb 570 Bob's public key, X25519(g, 9): 571 de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f 572 Their shared secret, K: 573 4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742 575 6.2. Curve448 577 The X448 function can be used in an ECDH protocol very much like the 578 X25519 function. 580 If X448 is to be used, the only differences are that Alice and Bob 581 generate 56 random bytes (not 32) and calculate K_A = X448(f, 5) or 582 K_B = X448(g, 5) where 5 is the u-coordinate of the base point and is 583 encoded as a byte with value 5, followed by 55 zero bytes. 585 As with X25519, both sides MUST check, without leaking extra 586 information about the value of K, whether the resulting shared K is 587 the all-zero value and abort if so. 589 Test vector: 591 Alice's private key, f: 592 9a8f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28d 593 d9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a598726b 594 Alice's public key, X448(f, 5): 595 9b08f7cc31b7e3e67d22d5aea121074a273bd2b83de09c63faa73d2c 596 22c5d9bbc836647241d953d40c5b12da88120d53177f80e532c41fa0 597 Bob's private key, g: 598 1c306a7ac2a0e2e0990b294470cba339e6453772b075811d8fad0d1d 599 6927c120bb5ee8972b0d3e21374c9c921b09d1b0366f10b65173992d 600 Bob's public key, X448(g, 5): 601 3eb7a829b0cd20f5bcfc0b599b6feccf6da4627107bdb0d4f345b430 602 27d8b972fc3e34fb4232a13ca706dcb57aec3dae07bdc1c67bf33609 603 Their shared secret, K: 604 07fff4181ac6cc95ec1c16a94a0f74d12da232ce40a77552281d282b 605 b60c0b56fd2464c335543936521c24403085d59a449a5037514a879d 607 7. Security Considerations 609 The security level (i.e. the number of "operations" needed for a 610 brute-force attack on a primitive) of curve25519 is slightly under 611 the standard 128-bit level. This is acceptable because the standard 612 security levels are primarily driven by much simplier, symmetric 613 primitives where the security level naturally falls on a power of 614 two. For asymmetric primitives, rigidly adhering to a power-of-two 615 security level would require compromises in other parts of the 616 design, which we reject. Additionally, comparing security levels 617 between types of primitives can be misleading under common threat 618 models where multiple targets can be attacked concurrently 619 [bruteforce]. 621 The ~224-bit security level of curve448 is a trade-off between 622 performance and paranoia. Large quantum computers, if ever created, 623 will break both curve25519 and curve448, and reasonable projections 624 of the abilities of classical computers conclude that curve25519 is 625 perfectly safe. However, some designs have relaxed performance 626 requirements and wish to hedge against some amount of analytical 627 advance against elliptic curves and thus curve448 is also provided. 629 8. IANA Considerations 631 This document has no actions for IANA. 633 9. Acknowledgements 635 This document merges draft-black-rpgecc-01 and draft-turner- 636 thecurve25519function-01. The following authors of those documents 637 wrote much of the text and figures but are not listed as authors on 638 this document: Benjamin Black, Joppe W. Bos, Craig Costello, Patrick 639 Longa, Michael Naehrig and Watson Ladd. 641 The authors would also like to thank Tanja Lange, Rene Struik, Rich 642 Salz, Ilari Liusvaara, Deirdre Connolly, Simon Josefsson, Stephen 643 Farrell and Georg Nestmann for their reviews and contributions. 645 The X25519 function was developed by Daniel J. Bernstein in 646 [curve25519]. 648 10. References 650 10.1. Normative References 652 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 653 Requirement Levels", BCP 14, RFC 2119, 654 DOI 10.17487/RFC2119, March 1997, 655 . 657 10.2. Informative References 659 [brainpool] 660 ECC Brainpool, "ECC Brainpool Standard Curves and Curve 661 Generation", October 2005, . 664 [bruteforce] 665 Bernstein, D., "Understanding brute force", April 2005, 666 . 668 [curve25519] 669 Bernstein, D., "Curve25519 -- new Diffie-Hellman speed 670 records", 2006, 671 . 674 [ed25519] Bernstein, D., Duif, N., Lange, T., Schwabe, P., and B. 675 Yang, "High-speed high-security signatures", 2011, 676 . 679 [goldilocks] 680 Hamburg, M., "Ed448-Goldilocks, a new elliptic curve", 681 2015, . 683 [montgomery] 684 Montgomery, P., "Speeding the Pollard and elliptic curve 685 methods of factorization", 1983, 686 . 689 [NIST] National Institute of Standards, "Recommended Elliptic 690 Curves for Federal Government Use", July 1999, 691 . 694 [reducing] 695 Menezes, A., Okamoto, T., and S. Vanstone, "Reducing 696 elliptic curve logarithms to logarithms in a finite 697 field", 1993, . 701 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 702 Curve Cryptography Algorithms", RFC 6090, 703 DOI 10.17487/RFC6090, February 2011, 704 . 706 [safecurves] 707 Bernstein, D. and T. Lange, "SafeCurves: choosing safe 708 curves for elliptic-curve cryptography", Oct 2013, 709 . 711 [satoh] Satoh, T. and K. Araki, "Fermat quotients and the 712 polynomial time discrete log algorithm for anomalous 713 elliptic curves", 1998. 715 [SEC1] Certicom Research, "SEC 1: Elliptic Curve Cryptography", 716 September 2000, 717 . 719 [semaev] Semaev, I., "Evaluation of discrete logarithms on some 720 elliptic curves", 1998. 722 [smart] Smart, N., "The discrete logarithm problem on elliptic 723 curves of trace one", 1999, 724 . 726 Appendix A. Deterministic Generation 728 This section specifies the procedure that was used to generate the 729 above curves; specifically it defines how to generate the parameter A 730 of the Montgomery curve y^2 = x^3 + Ax^2 + x. This procedure is 731 intended to be as objective as can reasonably be achieved so that 732 it's clear that no untoward considerations influenced the choice of 733 curve. The input to this process is p, the prime that defines the 734 underlying field. The size of p determines the amount of work needed 735 to compute a discrete logarithm in the elliptic curve group and 736 choosing a precise p depends on many implementation concerns. The 737 performance of the curve will be dominated by operations in GF(p) so 738 carefully choosing a value that allows for easy reductions on the 739 intended architecture is critical. This document does not attempt to 740 articulate all these considerations. 742 The value (A-2)/4 is used in several of the elliptic curve point 743 arithmetic formulas. For simplicity and performance reasons, it is 744 beneficial to make this constant small, i.e. to choose A so that 745 (A-2) is a small integer which is divisible by four. 747 For each curve at a specific security level: 749 1. The trace of Frobenius MUST NOT be in {0, 1} in order to rule out 750 the attacks described in [smart], [satoh], and [semaev], as in 751 [brainpool] and [safecurves]. 753 2. MOV Degree [reducing]: the embedding degree k MUST be greater 754 than (r - 1) / 100, as in [brainpool] and [safecurves]. 756 3. CM Discriminant: discriminant D MUST be greater than 2^100, as in 757 [safecurves]. 759 A.1. p = 1 mod 4 761 For primes congruent to 1 mod 4, the minimal cofactors of the curve 762 and its twist are either {4, 8} or {8, 4}. We choose a curve with the 763 latter cofactors so that any algorithms that take the cofactor into 764 account don't have to worry about checking for points on the twist, 765 because the twist cofactor will be the smaller of the two. 767 To generate the Montgomery curve we find the minimal, positive A 768 value, such that A > 2 and (A-2) is divisible by four and where the 769 cofactors are as desired. The find1Mod4 function in the following 770 Sage script returns this value given p: 772 773 def findCurve(prime, curveCofactor, twistCofactor): 774 F = GF(prime) 776 for A in xrange(3, 1e9): 777 if (A-2) % 4 != 0: 778 continue 780 try: 781 E = EllipticCurve(F, [0, A, 0, 1, 0]) 782 except: 783 continue 785 order = E.order() 786 twistOrder = 2*(prime+1)-order 788 if (order % curveCofactor == 0 and 789 is_prime(order // curveCofactor) and 790 twistOrder % twistCofactor == 0 and 791 is_prime(twistOrder // twistCofactor)): 792 return A 794 def find1Mod4(prime): 795 assert((prime % 4) == 1) 796 return findCurve(prime, 8, 4) 797 799 Generating a curve where p = 1 mod 4 801 A.2. p = 3 mod 4 803 For a prime congruent to 3 mod 4, both the curve and twist cofactors 804 can be 4 and this is minimal. Thus we choose the curve with these 805 cofactors and minimal, positive A such that A > 2 and (A-2) is 806 divisible by four. The find3Mod4 function in the following Sage 807 script returns this value given p: 809 810 def find3Mod4(prime): 811 assert((prime % 4) == 3) 812 return findCurve(prime, 4, 4) 813 815 Generating a curve where p = 3 mod 4 817 A.3. Base points 819 The base point for a curve is the point with minimal, positive u 820 value that is in the correct subgroup. The findBasepoint function in 821 the following Sage script returns this value given p and A: 823 824 def findBasepoint(prime, A): 825 F = GF(prime) 826 E = EllipticCurve(F, [0, A, 0, 1, 0]) 828 for uInt in range(1, 1e3): 829 u = F(uInt) 830 v2 = u^3 + A*u^2 + u 831 if not v2.is_square(): 832 continue 833 v = v2.sqrt() 835 point = E(u, v) 836 order = point.order() 837 if order > 8 and order.is_prime(): 838 return point 839 841 Generating the base point 843 Authors' Addresses 845 Adam Langley 846 Google 847 345 Spear St 848 San Francisco, CA 94105 849 US 851 Email: agl@google.com 853 Mike Hamburg 854 Rambus Cryptography Research 855 425 Market Street, 11th Floor 856 San Francisco, CA 94105 857 US 859 Email: mike@shiftleft.org 860 Sean Turner 861 IECA, Inc. 862 3057 Nutley Street 863 Suite 106 864 Fairfax, VA 22031 865 US 867 Email: turners@ieca.com