idnits 2.17.1 draft-irtf-cfrg-spake2-11.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 (June 8, 2020) is 1418 days in the past. Is this intentional? Checking references for intended status: Informational ---------------------------------------------------------------------------- == Missing Reference: '-1' is mentioned on line 552, but not defined -- Looks like a reference, but probably isn't: '0' on line 554 == Unused Reference: 'TDH' is defined on line 490, but no explicit reference was found in the text == Outdated reference: A later version (-16) exists of draft-irtf-cfrg-hash-to-curve-05 Summary: 0 errors (**), 0 flaws (~~), 4 warnings (==), 2 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group W. Ladd 3 Internet-Draft Cloudflare 4 Intended status: Informational B. Kaduk, Ed. 5 Expires: December 10, 2020 Akamai 6 June 8, 2020 8 SPAKE2, a PAKE 9 draft-irtf-cfrg-spake2-11 11 Abstract 13 This document describes SPAKE2 which is a protocol for two parties 14 that share a password to derive a strong shared key with no risk of 15 disclosing the password. This method is compatible with any group, 16 is computationally efficient, and SPAKE2 has a security proof. This 17 document predated the CFRG PAKE competition and it was not selected. 19 Status of This Memo 21 This Internet-Draft is submitted in full conformance with the 22 provisions of BCP 78 and BCP 79. 24 Internet-Drafts are working documents of the Internet Engineering 25 Task Force (IETF). Note that other groups may also distribute 26 working documents as Internet-Drafts. The list of current Internet- 27 Drafts is at https://datatracker.ietf.org/drafts/current/. 29 Internet-Drafts are draft documents valid for a maximum of six months 30 and may be updated, replaced, or obsoleted by other documents at any 31 time. It is inappropriate to use Internet-Drafts as reference 32 material or to cite them other than as "work in progress." 34 This Internet-Draft will expire on December 10, 2020. 36 Copyright Notice 38 Copyright (c) 2020 IETF Trust and the persons identified as the 39 document authors. All rights reserved. 41 This document is subject to BCP 78 and the IETF Trust's Legal 42 Provisions Relating to IETF Documents 43 (https://trustee.ietf.org/license-info) in effect on the date of 44 publication of this document. Please review these documents 45 carefully, as they describe your rights and restrictions with respect 46 to this document. Code Components extracted from this document must 47 include Simplified BSD License text as described in Section 4.e of 48 the Trust Legal Provisions and are provided without warranty as 49 described in the Simplified BSD License. 51 Table of Contents 53 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 54 2. Requirements Notation . . . . . . . . . . . . . . . . . . . . 2 55 3. Definition of SPAKE2 . . . . . . . . . . . . . . . . . . . . 2 56 4. Key Schedule and Key Confirmation . . . . . . . . . . . . . . 5 57 5. Per-User M and N . . . . . . . . . . . . . . . . . . . . . . 6 58 6. Ciphersuites . . . . . . . . . . . . . . . . . . . . . . . . 6 59 7. Security Considerations . . . . . . . . . . . . . . . . . . . 9 60 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 9 61 9. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 9 62 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 9 63 Appendix A. Algorithm used for Point Generation . . . . . . . . 11 64 Appendix B. Test Vectors . . . . . . . . . . . . . . . . . . . . 13 65 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 16 67 1. Introduction 69 This document describes SPAKE2, a means for two parties that share a 70 password to derive a strong shared key with no risk of disclosing the 71 password. This password-based key exchange protocol is compatible 72 with any group (requiring only a scheme to map a random input of 73 fixed length per group to a random group element), is computationally 74 efficient, and has a security proof. Predetermined parameters for a 75 selection of commonly used groups are also provided for use by other 76 protocols. 78 2. Requirements Notation 80 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 81 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 82 "OPTIONAL" in this document are to be interpreted as described in BCP 83 14 [RFC2119] [RFC8174] when, and only when, they appear in all 84 capitals, as shown here. 86 3. Definition of SPAKE2 88 3.1. Setup 90 Let G be a group in which the computational Diffie-Hellman (CDH) 91 problem is hard. Suppose G has order p*h where p is a large prime; h 92 will be called the cofactor. Let I be the unit element in G, e.g., 93 the point at infinity if G is an elliptic curve group. We denote the 94 operations in the group additively. We assume there is a 95 representation of elements of G as byte strings: common choices would 96 be SEC1 [SEC1] uncompressed or compressed for elliptic curve groups 97 or big endian integers of a fixed (per-group) length for prime field 98 DH. We fix two elements M and N in the prime-order subgroup of G as 99 defined in the table in this document for common groups, as well as a 100 generator P of the (large) prime-order subgroup of G. In the case of 101 a composite order group we will work in the quotient group. P is 102 specified in the document defining the group, and so we do not repeat 103 it here. 105 || denotes concatenation of strings. We also let len(S) denote the 106 length of a string in bytes, represented as an eight-byte little- 107 endian number. Finally, let nil represent an empty string, i.e., 108 len(nil) = 0. 110 KDF is a key-derivation function that takes as input a salt, 111 intermediate keying material (IKM), info string, and derived key 112 length L to derive a cryptographic key of length L. MAC is a Message 113 Authentication Code algorithm that takes a secret key and message as 114 input to produce an output. Let Hash be a hash function from 115 arbitrary strings to bit strings of a fixed length. Common choices 116 for H are SHA256 or SHA512 [RFC6234]. Let MHF be a memory-hard hash 117 function designed to slow down brute-force attackers. Scrypt 118 [RFC7914] is a common example of this function. The output length of 119 MHF matches that of Hash. Parameter selection for MHF is out of 120 scope for this document. Section 6 specifies variants of KDF, MAC, 121 and Hash suitable for use with the protocols contained herein. 123 Let A and B be two parties. A and B may also have digital 124 representations of the parties' identities such as Media Access 125 Control addresses or other names (hostnames, usernames, etc). A and 126 B may share Additional Authenticated Data (AAD) of length at most 127 2^16 - 1 bits that is separate from their identities which they may 128 want to include in the protocol execution. One example of AAD is a 129 list of supported protocol versions if SPAKE2(+) were used in a 130 higher-level protocol which negotiates use of a particular PAKE. 131 Including this list would ensure that both parties agree upon the 132 same set of supported protocols and therefore prevent downgrade 133 attacks. We also assume A and B share an integer w; typically w = 134 MHF(pw) mod p, for a user-supplied password pw. Standards such as 135 NIST.SP.800-56Ar3 suggest taking mod p of a hash value that is 64 136 bits longer than that needed to represent p to remove statistical 137 bias introduced by the modulation. Protocols using this 138 specification must define the method used to compute w: it may be 139 necessary to carry out various forms of normalization of the password 140 before hashing [RFC8265]. The hashing algorithm SHOULD be a MHF so 141 as to slow down brute-force attackers. 143 3.2. Protocol Flow 145 SPAKE2 is a one round protocol to establish a shared secret with an 146 additional round for key confirmation. Prior to invocation, A and B 147 are provisioned with information such as the input password needed to 148 run the protocol. During the first round, A sends a public share pA 149 to B, and B responds with its own public share pB. Both A and B then 150 derive a shared secret used to produce encryption and authentication 151 keys. The latter are used during the second round for key 152 confirmation. (Section 4 details the key derivation and confirmation 153 steps.) In particular, A sends a key confirmation message cA to B, 154 and B responds with its own key confirmation message cB. Both 155 parties MUST NOT consider the protocol complete prior to receipt and 156 validation of these key confirmation messages. 158 This sample trace is shown below. 160 A B 161 | (setup protocol) | 162 (compute pA) | pA | 163 |----------------->| 164 | pB | (compute pB) 165 |<-----------------| 166 | | 167 | (derive secrets) | 168 (compute cA) | cA | 169 |----------------->| 170 | cB | (compute cB) 171 |<-----------------| 173 3.3. SPAKE2 175 To begin, A picks x randomly and uniformly from the integers in 176 [0,p), and calculates X=x*P and T=w*M+X, then transmits pA=T to B. 178 B selects y randomly and uniformly from the integers in [0,p), and 179 calculates Y=y*P, S=w*N+Y, then transmits pB=S to A. 181 Both A and B calculate a group element K. A calculates it as 182 h*x*(S-w*N), while B calculates it as h*y*(T-w*M). A knows S because 183 it has received it, and likewise B knows T. The multiplication by h 184 prevents small subgroup confinement attacks by computing a unique 185 value in the quotient group. This is a common mitigation against 186 this kind of attack. 188 K is a shared value, though it MUST NOT be used as a shared secret. 189 Both A and B must derive two shared secrets from the protocol 190 transcript. This prevents man-in-the-middle attackers from inserting 191 themselves into the exchange. The transcript TT is encoded as 192 follows: 194 TT = len(A) || A 195 || len(B) || B 196 || len(S) || S 197 || len(T) || T 198 || len(K) || K 199 || len(w) || w 201 If an identity is absent, it is omitted from the transcript entirely. 202 For example, if both A and B are absent, then: 204 TT = len(S) || S 205 || len(T) || T 206 || len(K) || K 207 || len(w) || w 209 Likewise, if only A is absent, then: 211 TT = len(B) || B 212 || len(S) || S 213 || len(T) || T 214 || len(K) || K 215 || len(w) || w 217 This must only be done for applications in which identities are 218 implicit. Otherwise, the protocol risks Unknown Key Share attacks 219 (discussion of Unknown Key Share attacks in a specific protocol is 220 given in [I-D.ietf-mmusic-sdp-uks]). 222 Upon completion of this protocol, A and B compute shared secrets Ke, 223 KcA, and KcB as specified in Section 4. A MUST send B a key 224 confirmation message so both parties agree upon these shared secrets. 225 This confirmation message F is computed as a MAC over the protocol 226 transcript TT using KcA, as follows: F = MAC(KcA, TT). Similarly, B 227 MUST send A a confirmation message using a MAC computed equivalently 228 except with the use of KcB. Key confirmation verification requires 229 computing F and checking for equality against that which was 230 received. 232 4. Key Schedule and Key Confirmation 234 The protocol transcript TT, as defined in Section Section 3.3, is 235 unique and secret to A and B. Both parties use TT to derive shared 236 symmetric secrets Ke and Ka as Ke || Ka = Hash(TT), with |Ke| = |Ka|. 237 The length of each key is equal to half of the digest output, e.g., 238 128 bits for SHA-256. 240 Both endpoints use Ka to derive subsequent MAC keys for key 241 confirmation messages. Specifically, let KcA and KcB be the MAC keys 242 used by A and B, respectively. A and B compute them as KcA || KcB = 243 KDF(nil, Ka, "ConfirmationKeys" || AAD), where AAD is the associated 244 data each given to each endpoint, or nil if none was provided. The 245 length of each of KcA and KcB is equal to half of the KDF output, 246 e.g., |KcA| = |KcB| = 128 bits for HKDF(SHA256). 248 The resulting key schedule for this protocol, given transcript TT and 249 additional associated data AAD, is as follows. 251 TT -> Hash(TT) = Ka || Ke 252 AAD -> KDF(nil, Ka, "ConfirmationKeys" || AAD) = KcA || KcB 254 A and B output Ke as the shared secret from the protocol. Ka and its 255 derived keys are not used for anything except key confirmation. 257 5. Per-User M and N 259 To avoid concerns that an attacker needs to solve a single ECDH 260 instance to break the authentication of SPAKE2, a variant based on 261 using [I-D.irtf-cfrg-hash-to-curve] is also presented. In this 262 variant, M and N are computed as follows: 264 M = h2c(Hash("M for SPAKE2" || len(A) || A || len(B) || B)) 265 N = h2c(Hash("N for SPAKE2" || len(A) || A || len(B) || B)) 267 In addition M and N may be equal to have a symmetric variant. The 268 security of these variants is examined in [MNVAR]. 270 6. Ciphersuites 272 This section documents SPAKE2 ciphersuite configurations. A 273 ciphersuite indicates a group, cryptographic hash algorithm, and pair 274 of KDF and MAC functions, e.g., SPAKE2-P256-SHA256-HKDF-HMAC. This 275 ciphersuite indicates a SPAKE2 protocol instance over P-256 that uses 276 SHA256 along with HKDF [RFC5869] and HMAC [RFC2104] for G, Hash, KDF, 277 and MAC functions, respectively. 279 +------------------+---------------+-------------+------------------+ 280 | G | Hash | KDF | MAC | 281 +------------------+---------------+-------------+------------------+ 282 | P-256 | SHA256 | HKDF | HMAC [RFC2104] | 283 | | [RFC6234] | [RFC5869] | | 284 | | | | | 285 | P-256 | SHA512 | HKDF | HMAC [RFC2104] | 286 | | [RFC6234] | [RFC5869] | | 287 | | | | | 288 | P-384 | SHA256 | HKDF | HMAC [RFC2104] | 289 | | [RFC6234] | [RFC5869] | | 290 | | | | | 291 | P-384 | SHA512 | HKDF | HMAC [RFC2104] | 292 | | [RFC6234] | [RFC5869] | | 293 | | | | | 294 | P-512 | SHA512 | HKDF | HMAC [RFC2104] | 295 | | [RFC6234] | [RFC5869] | | 296 | | | | | 297 | edwards25519 | SHA256 | HKDF | HMAC [RFC2104] | 298 | [RFC7748] | [RFC6234] | [RFC5869] | | 299 | | | | | 300 | edwards448 | SHA512 | HKDF | HMAC [RFC2104] | 301 | [RFC7748] | [RFC6234] | [RFC5869] | | 302 | | | | | 303 | P-256 | SHA256 | HKDF | CMAC-AES-128 | 304 | | [RFC6234] | [RFC5869] | [RFC4493] | 305 | | | | | 306 | P-256 | SHA512 | HKDF | CMAC-AES-128 | 307 | | [RFC6234] | [RFC5869] | [RFC4493] | 308 +------------------+---------------+-------------+------------------+ 310 Table 1: SPAKE2 Ciphersuites 312 The following points represent permissible point generation seeds for 313 the groups listed in the Table Table 1, using the algorithm presented 314 in Appendix A. These bytestrings are compressed points as in [SEC1] 315 for curves from [SEC1]. 317 For P256: 319 M = 320 02886e2f97ace46e55ba9dd7242579f2993b64e16ef3dcab95afd497333d8fa12f 321 seed: 1.2.840.10045.3.1.7 point generation seed (M) 323 N = 324 03d8bbd6c639c62937b04d997f38c3770719c629d7014d49a24b4f98baa1292b49 325 seed: 1.2.840.10045.3.1.7 point generation seed (N) 326 For P384: 328 M = 329 030ff0895ae5ebf6187080a82d82b42e2765e3b2f8749c7e05eba366434b363d3dc 330 36f15314739074d2eb8613fceec2853 331 seed: 1.3.132.0.34 point generation seed (M) 333 N = 334 02c72cf2e390853a1c1c4ad816a62fd15824f56078918f43f922ca21518f9c543bb 335 252c5490214cf9aa3f0baab4b665c10 336 seed: 1.3.132.0.34 point generation seed (N) 338 For P521: 340 M = 341 02003f06f38131b2ba2600791e82488e8d20ab889af753a41806c5db18d37d85608 342 cfae06b82e4a72cd744c719193562a653ea1f119eef9356907edc9b56979962d7aa 343 seed: 1.3.132.0.35 point generation seed (M) 345 N = 346 0200c7924b9ec017f3094562894336a53c50167ba8c5963876880542bc669e494b25 347 32d76c5b53dfb349fdf69154b9e0048c58a42e8ed04cef052a3bc349d95575cd25 348 seed: 1.3.132.0.35 point generation seed (N) 350 For edwards25519: 352 M = 353 d048032c6ea0b6d697ddc2e86bda85a33adac920f1bf18e1b0c6d166a5cecdaf 354 seed: edwards25519 point generation seed (M) 356 N = 357 d3bfb518f44f3430f29d0c92af503865a1ed3281dc69b35dd868ba85f886c4ab 358 seed: edwards25519 point generation seed (N) 360 For edwards448: 362 M = 363 b6221038a775ecd007a4e4dde39fd76ae91d3cf0cc92be8f0c2fa6d6b66f9a12 364 942f5a92646109152292464f3e63d354701c7848d9fc3b8880 365 seed: edwards448 point generation seed (M) 367 N = 368 6034c65b66e4cd7a49b0edec3e3c9ccc4588afd8cf324e29f0a84a072531c4db 369 f97ff9af195ed714a689251f08f8e06e2d1f24a0ffc0146600 370 seed: edwards448 point generation seed (N) 372 7. Security Considerations 374 A security proof of SPAKE2 for prime order groups is found in [REF]. 375 Note that the choice of M and N is critical for the security proof. 376 The generation method specified in this document is designed to 377 eliminate concerns related to knowing discrete logs of M and N. 379 Elements received from a peer MUST be checked for group membership: 380 failure to properly validate group elements can lead to attacks. It 381 is essential that endpoints verify received points are members of G. 383 The choices of random numbers MUST BE uniform. Randomly generated 384 values (e.g., x and y) MUST NOT be reused; such reuse may permit 385 dictionary attacks on the password. 387 SPAKE2 does not support augmentation. As a result, the server has to 388 store a password equivalent. This is considered a significant 389 drawback in some use cases 391 8. IANA Considerations 393 No IANA action is required. 395 9. Acknowledgments 397 Special thanks to Nathaniel McCallum and Greg Hudson for generation 398 of test vectors. Thanks to Mike Hamburg for advice on how to deal 399 with cofactors. Greg Hudson also suggested the addition of warnings 400 on the reuse of x and y. Thanks to Fedor Brunner, Adam Langley, and 401 the members of the CFRG for comments and advice. Chris Wood 402 contributed substantial text and reformatting to address the 403 excellent review comments from Kenny Paterson. 405 10. References 407 10.1. Normative References 409 [I-D.irtf-cfrg-hash-to-curve] 410 Faz-Hernandez, A., Scott, S., Sullivan, N., Wahby, R., and 411 C. Wood, "Hashing to Elliptic Curves", draft-irtf-cfrg- 412 hash-to-curve-05 (work in progress), November 2019. 414 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 415 Hashing for Message Authentication", RFC 2104, 416 DOI 10.17487/RFC2104, February 1997, 417 . 419 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 420 Requirement Levels", BCP 14, RFC 2119, 421 DOI 10.17487/RFC2119, March 1997, 422 . 424 [RFC4493] Song, JH., Poovendran, R., Lee, J., and T. Iwata, "The 425 AES-CMAC Algorithm", RFC 4493, DOI 10.17487/RFC4493, June 426 2006, . 428 [RFC5480] Turner, S., Brown, D., Yiu, K., Housley, R., and T. Polk, 429 "Elliptic Curve Cryptography Subject Public Key 430 Information", RFC 5480, DOI 10.17487/RFC5480, March 2009, 431 . 433 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 434 Key Derivation Function (HKDF)", RFC 5869, 435 DOI 10.17487/RFC5869, May 2010, 436 . 438 [RFC6234] Eastlake 3rd, D. and T. Hansen, "US Secure Hash Algorithms 439 (SHA and SHA-based HMAC and HKDF)", RFC 6234, 440 DOI 10.17487/RFC6234, May 2011, 441 . 443 [RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves 444 for Security", RFC 7748, DOI 10.17487/RFC7748, January 445 2016, . 447 [RFC7914] Percival, C. and S. Josefsson, "The scrypt Password-Based 448 Key Derivation Function", RFC 7914, DOI 10.17487/RFC7914, 449 August 2016, . 451 [RFC8032] Josefsson, S. and I. Liusvaara, "Edwards-Curve Digital 452 Signature Algorithm (EdDSA)", RFC 8032, 453 DOI 10.17487/RFC8032, January 2017, 454 . 456 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 457 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 458 May 2017, . 460 10.2. Informative References 462 [I-D.ietf-mmusic-sdp-uks] 463 Thomson, M. and E. Rescorla, "Unknown Key Share Attacks on 464 uses of TLS with the Session Description Protocol (SDP)", 465 draft-ietf-mmusic-sdp-uks-07 (work in progress), August 466 2019. 468 [MNVAR] Abdalla, M. and M. Barbosa, "Perfect Forward Security of 469 SPAKE2", Oct 2019. 471 IACR eprint 2019/1194 473 [REF] Abdalla, M. and D. Pointcheval, "Simple Password-Based 474 Encrypted Key Exchange Protocols.", Feb 2005. 476 Appears in A. Menezes, editor. Topics in Cryptography- 477 CT-RSA 2005, Volume 3376 of Lecture Notes in Computer 478 Science, pages 191-208, San Francisco, CA, US. Springer- 479 Verlag, Berlin, Germany. 481 [RFC8265] Saint-Andre, P. and A. Melnikov, "Preparation, 482 Enforcement, and Comparison of Internationalized Strings 483 Representing Usernames and Passwords", RFC 8265, 484 DOI 10.17487/RFC8265, October 2017, 485 . 487 [SEC1] Standards for Efficient Cryptography Group, "SEC 1: 488 Elliptic Curve Cryptography", May 2009. 490 [TDH] Cash, D., Kiltz, E., and V. Shoup, "The Twin-Diffie 491 Hellman Problem and Applications", 2008. 493 EUROCRYPT 2008. Volume 4965 of Lecture notes in Computer 494 Science, pages 127-145. Springer-Verlag, Berlin, Germany. 496 Appendix A. Algorithm used for Point Generation 498 This section describes the algorithm that was used to generate the 499 points (M) and (N) in the table in Section 6. 501 For each curve in the table below, we construct a string using the 502 curve OID from [RFC5480] (as an ASCII string) or its name, combined 503 with the needed constant, for instance "1.3.132.0.35 point generation 504 seed (M)" for P-512. This string is turned into a series of blocks 505 by hashing with SHA256, and hashing that output again to generate the 506 next 32 bytes, and so on. This pattern is repeated for each group 507 and value, with the string modified appropriately. 509 A byte string of length equal to that of an encoded group element is 510 constructed by concatenating as many blocks as are required, starting 511 from the first block, and truncating to the desired length. The byte 512 string is then formatted as required for the group. In the case of 513 Weierstrass curves, we take the desired length as the length for 514 representing a compressed point (section 2.3.4 of [SEC1]), and use 515 the low-order bit of the first byte as the sign bit. In order to 516 obtain the correct format, the value of the first byte is set to 0x02 517 or 0x03 (clearing the first six bits and setting the seventh bit), 518 leaving the sign bit as it was in the byte string constructed by 519 concatenating hash blocks. For the [RFC8032] curves a different 520 procedure is used. For edwards448 the 57-byte input has the least- 521 significant 7 bits of the last byte set to zero, and for edwards25519 522 the 32-byte input is not modified. For both the [RFC8032] curves the 523 (modified) input is then interpreted as the representation of the 524 group element. If this interpretation yields a valid group element 525 with the correct order (p), the (modified) byte string is the output. 526 Otherwise, the initial hash block is discarded and a new byte string 527 constructed from the remaining hash blocks. The procedure of 528 constructing a byte string of the appropriate length, formatting it 529 as required for the curve, and checking if it is a valid point of the 530 correct order, is repeated until a valid element is found. 532 The following python snippet generates the above points, assuming an 533 elliptic curve implementation following the interface of 534 Edwards25519Point.stdbase() and Edwards448Point.stdbase() in 535 Appendix A of [RFC8032]: 537 def iterated_hash(seed, n): 538 h = seed 539 for i in range(n): 540 h = hashlib.sha256(h).digest() 541 return h 543 def bighash(seed, start, sz): 544 n = -(-sz // 32) 545 hashes = [iterated_hash(seed, i) for i in range(start, start + n)] 546 return b''.join(hashes)[:sz] 548 def canon_pointstr(ecname, s): 549 if ecname == 'edwards25519': 550 return s 551 elif ecname == 'edwards448': 552 return s[:-1] + bytes([s[-1] & 0x80]) 553 else: 554 return bytes([(s[0] & 1) | 2]) + s[1:] 556 def gen_point(seed, ecname, ec): 557 for i in range(1, 1000): 558 hval = bighash(seed, i, len(ec.encode())) 559 pointstr = canon_pointstr(ecname, hval) 560 try: 561 p = ec.decode(pointstr) 562 if p != ec.zero_elem() and p * p.l() == ec.zero_elem(): 563 return pointstr, i 564 except Exception: 565 pass 567 Appendix B. Test Vectors 569 This section contains test vectors for SPAKE2 using the P256-SHA256- 570 HKDF-HMAC ciphersuite. (Choice of MHF is omitted and values for w 571 and w0,w1 are provided directly.) All points are encoded using the 572 uncompressed format, i.e., with a 0x04 octet prefix, specified in 573 [SEC1] A and B identity strings are provided in the protocol 574 invocation. 576 B.1. SPAKE2 Test Vectors 578 SPAKE2(A='client', B='server') 579 w = 0x7741cf8c80b9bee583abac3d38daa6b807fed38b06580cb75ee85319d25fed 580 e6 581 X = 0x04ac6827b3a9110d1e663bcd4f5de668da34a9f45e464e99067bbea53f1ed4 582 d8abbdd234c05b3a3a8a778ee47f244cca1a79acb7052d5e58530311a9af077ba179 583 T = 0x04e02acfbbfb081fc38b5bab999b5e25a5ffd0b1ac48eae24fcc8e49ac5e0d 584 8a790914419a100e205605f9862daa848e99cea455263f0c6e06bc5a911f3e10a16b 585 Y = 0x0413c45ab093a75c4b2a6e71f957eec3859807858325258b0fa43df5a6efd2 586 63c59b9c1fbfd55bc5e75fd3e7ba8af6799a99b225fe6c30e6c2a2e0ab4962136ba8 587 S = 0x047aad50ba7bd6a5eacbead7689f7146f1a4219fa071cce1755f80280cc6c3 588 a5a73cf469f2a294a0b74a5c07054585ccd447f3f633d8631f3bf43442449e9efeba 589 TT = 0x0600000000000000636c69656e74060000000000000073657276657241000 590 00000000000047aad50ba7bd6a5eacbead7689f7146f1a4219fa071cce1755f80280 591 cc6c3a5a73cf469f2a294a0b74a5c07054585ccd447f3f633d8631f3bf43442449e9 592 efeba410000000000000004e02acfbbfb081fc38b5bab999b5e25a5ffd0b1ac48eae 593 24fcc8e49ac5e0d8a790914419a100e205605f9862daa848e99cea455263f0c6e06b 594 c5a911f3e10a16b410000000000000004d01fc08bbae9b6abe2f4d6893cc9f810433 595 2e19be5f5881c6b9f077e1feff55023da74db65fae320fad8f0dd38e1323f5336f3f 596 53c9c9dec06710f18f556bd2020000000000000007741cf8c80b9bee583abac3d38d 597 aa6b807fed38b06580cb75ee85319d25fede6 598 Ka = 0x2b5e350c58d530c3586f75bf2a155c4b 599 Ke = 0x238509f7adf0dc72500b2d1315737a27 600 KcA = 0xc33d2ef8e37a7e545c14c7fcfdc9db94 601 KcB = 0x18a81cec7eb83416db6615cb3bc03fcb 602 MAC(A) = 0x29e9a63d243f2f0db5532d2eb0dbaa617803b85feb31566d0cb9457e3 603 03bcfa6 604 MAC(B) = 0x487e4cbe98b6287272d043e169a19b6c4682d0481c92f53f1ee03d4b8 605 6c3f43e 607 SPAKE2(A='client', B='') 608 w = 0x7741cf8c80b9bee583abac3d38daa6b807fed38b06580cb75ee85319d25fed 609 e6 610 X = 0x048b5d7b44b02c4c868f4486ec55bd2380ec34cd5fa5dbff1079a79097e305 611 0b34fa91272331729357c86cbb30d371e252dc915aeaa314921b1f09f74816f96a12 612 T = 0x04839f44931b88d12769e601d0ec480b6c9ea95e70ba361ba14bf513e5186a 613 6c302e6f409bd01f1030ad3cdac1e08965217e430ca7f9bce698111ae8a4d0530efd 614 Y = 0x0446419d63037d0bbaca224f89987c776bfea2e0913ccda0790079212f476d 615 6fd1ec997a02821a804f885e4f29b172b27c92251d883efe201cae106c239108c0c7 616 S = 0x042926b2dbcc5d0cb23ca123cc4133242f2998439af5380434a4bd5fd76fbb 617 c030b5563218d0184fa3fd303482a679c9555ccea41098b26b6ee16fe35c792b1fda 618 TT = 0x0600000000000000636c69656e744100000000000000042926b2dbcc5d0cb 619 23ca123cc4133242f2998439af5380434a4bd5fd76fbbc030b5563218d0184fa3fd3 620 03482a679c9555ccea41098b26b6ee16fe35c792b1fda410000000000000004839f4 621 4931b88d12769e601d0ec480b6c9ea95e70ba361ba14bf513e5186a6c302e6f409bd 622 01f1030ad3cdac1e08965217e430ca7f9bce698111ae8a4d0530efd4100000000000 623 000041d9e3c88db68247ab50264a6090e2e524bda3049dbc53c4df708e37bd76913b 624 8cf5954c4d0f835331f185fef4ff1c6115cf0eb8ce27e8224bf5f76c75b182308200 625 00000000000007741cf8c80b9bee583abac3d38daa6b807fed38b06580cb75ee8531 626 9d25fede6 627 Ka = 0xfc8482d5d7623a75ad09721d631d1392 628 Ke = 0x93f618fe24d0d5a54b320f498dbd3ecb 629 KcA = 0x75b20fc4205d6217a22156f918dd03b1 630 KcB = 0x3bf3a5d3876d9d12dc54cab927acd5f7 631 MAC(A) = 0xd4994b751eb832b2836ad674cd615c643053278864a63e263bc2f324b 632 9a04ddd 633 MAC(B) = 0x23cf761999b7603adf5507b50c9bda4eaabe8fa7a9ad0280729dfcd00 634 8b2bf05 636 SPAKE2(A='', B='server') 637 w = 0x7741cf8c80b9bee583abac3d38daa6b807fed38b06580cb75ee85319d25fed 638 e6 639 X = 0x0465e8b4709ba622bc97af5dde3b41757c2114bfc5abb10141245cb01d62ca 640 0d7360e1169cd518f9351bbfa44a66cc5f3bcb60661a04f39b04a3d504046db67884 641 T = 0x0482f64286419ff46362faf781776edf908740b8ff612e0bfe3c90cdc553ba 642 db7f882a4110ee71fa13a693b5ce96ceba5798636555d074648d4521e3b63dc14872 643 Y = 0x041aa11299692627a7cac122d4c14606ff700a8be6a0fb1c42f3762d629893 644 ab3ca51e4a48c798fc8c6b9dcfda1ad33099ed2f73abe6b3500ce383f54011430c26 645 S = 0x04adba3c3b9a74d9769651d09aedb37d22b9471b9e408e2b98fdd4188c12fa 646 c731e9dc87e029f7dee0213660ddf0791f50dd8fd32f7152015be0489125b3831b4b 647 TT = 0x0600000000000000736572766572410000000000000004adba3c3b9a74d97 648 69651d09aedb37d22b9471b9e408e2b98fdd4188c12fac731e9dc87e029f7dee0213 649 660ddf0791f50dd8fd32f7152015be0489125b3831b4b41000000000000000482f64 650 286419ff46362faf781776edf908740b8ff612e0bfe3c90cdc553badb7f882a4110e 651 e71fa13a693b5ce96ceba5798636555d074648d4521e3b63dc148724100000000000 652 00004a406929024a5275372531c85c54fd222f35bfdb1cdf1bd1abe82d5c837744d9 653 3ea2979962eb374d4feda37b178e91711c52edd453178cf69748e0a3d9ef073c2200 654 00000000000007741cf8c80b9bee583abac3d38daa6b807fed38b06580cb75ee8531 655 9d25fede6 656 Ka = 0xcd9c33c6329761919486d0041faccb56 657 Ke = 0xa08125eeed51c61ad93b2ff7d8ec3cd5 658 KcA = 0x60056386cbe06ba199fa6aef81dfb273 659 KcB = 0x5e5a591b4426d47190aecb2fc4527140 660 MAC(A) = 0xf0dcfb4fa874e3fcbadd44b6eb26a64d1d5c6e50034934934551f172d 661 3cdc50e 662 MAC(B) = 0x52e7a505c0b73db656108554a854c3f33bfb01edcc1ee52aa27ceb1cb 663 ef7f47b 665 SPAKE2(A='', B='') 666 w = 0x7741cf8c80b9bee583abac3d38daa6b807fed38b06580cb75ee85319d25fed 667 e6 668 X = 0x04fbeb44d6b772fa390fcced51be7316107e608ddf4ab5dcc9f1b2e24bf667 669 7f3232cdeeb39a61621a9e48028997d449894212eb54b6f12bdbd9baf8f1c909a740 670 T = 0x04887af8439d743215f26d48314835b024b9301ea508eac3a339241672fbba 671 09f63e155b1df5d31ccc63babafc00ffff6e258c692aed84a859fd4960d99fcec777 672 Y = 0x04bb4727c5c5c50ae34d5148ec6797e5ebf93ae51c5c6cfd48579c41436823 673 1ac8769142bf6a0109bd2b86dd901c6054629ce2c6b982326c9cd9a3685c4cf0640d 674 S = 0x04665b5101132528be32f4b4762d6ae80273bbe74e151fc2320da373e146ee 675 cd33038ff8099782f3781160244672cb43b4d9f2007da9b617c1890845440da0ca53 676 TT = 0x410000000000000004665b5101132528be32f4b4762d6ae80273bbe74e151 677 fc2320da373e146eecd33038ff8099782f3781160244672cb43b4d9f2007da9b617c 678 1890845440da0ca53410000000000000004887af8439d743215f26d48314835b024b 679 9301ea508eac3a339241672fbba09f63e155b1df5d31ccc63babafc00ffff6e258c6 680 92aed84a859fd4960d99fcec777410000000000000004aacd2378990cecd338c7cac 681 d132ce633bc424ac5d4ab32f539ccf31f15deef62463253790e139b461c5137944fc 682 6a5ffd895dbe0d3960b01f6d662fc41057a7020000000000000007741cf8c80b9bee 683 583abac3d38daa6b807fed38b06580cb75ee85319d25fede6 684 Ka = 0x16b10f1541c24c630f462f7e0aa57ddf 685 Ke = 0xb7ae8b61938e3dfad8b9ce1d2865533f 686 KcA = 0x3398d6c7de402a9ae89a4594d5576c21 687 KcB = 0x6894ab44d7ba7f3a40a772d1476593d9 688 MAC(A) = 0x12fce7f0aecc1dba393a7e5612e6357becc5e3d07cd41ffd35c6d652f 689 29cde60 690 MAC(B) = 0xac36c6d186c3b824f4cfe099f035cf3aed4162d08886d32fa1806e5bf 691 4015255 693 Authors' Addresses 695 Watson Ladd 696 Cloudflare 698 Email: watsonbladd@gmail.com 700 Benjamin Kaduk (editor) 701 Akamai Technologies 703 Email: kaduk@mit.edu