Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Poly1305

From Wikipedia, the free encyclopedia
Universal hash family used for message authentication in cryptography

Poly1305 is auniversal hash family designed byDaniel J. Bernstein in 2002 for use incryptography.[1][2]

As with any universal hash family, Poly1305 can be used as a one-timemessage authentication code to authenticate a single message using a secret key shared between sender and recipient,[3]similar to the way that aone-time pad can be used to conceal the content of a single message using a secret key shared between sender and recipient.

Originally Poly1305 was proposed as part of Poly1305-AES,[2] a Carter–Wegman authenticator[4][5][1]that combines the Poly1305 hash withAES-128 to authenticate many messages using a single short key and distinct message numbers.Poly1305 was later applied with a single-use key generated for each message usingXSalsa20 in theNaCl crypto_secretbox_xsalsa20poly1305 authenticated cipher,[6]and then usingChaCha in theChaCha20-Poly1305 authenticated cipher[7][8][1]deployed inTLS on the internet.[9]

Description

[edit]

Definition of Poly1305

[edit]

Poly1305 takes a 16-byte secret keyr{\displaystyle r} and anL{\displaystyle L}-byte messagem{\displaystyle m} and returns a 16-byte hashPoly1305r(m){\displaystyle \operatorname {Poly1305} _{r}(m)}.To do this, Poly1305:[2][1]

  1. Interpretsr{\displaystyle r} as alittle-endian 16-byte integer.
  2. Breaks the messagem=(m[0],m[1],m[2],,m[L1]){\displaystyle m=(m[0],m[1],m[2],\dotsc ,m[L-1])} into consecutive 16-byte chunks.
  3. Interprets the 16-byte chunks as 17-byte little-endian integers by appending a 1 byte to every 16-byte chunk, to be used as coefficients of a polynomial.
  4. Evaluates the polynomial at the pointr{\displaystyle r} modulo the prime21305{\displaystyle 2^{130}-5}.
  5. Reduces the result modulo2128{\displaystyle 2^{128}} encoded in little-endian return a 16-byte hash.

The coefficientsci{\displaystyle c_{i}} of the polynomialc1rq+c2rq1++cqr{\displaystyle c_{1}r^{q}+c_{2}r^{q-1}+\cdots +c_{q}r}, whereq=L/16{\displaystyle q=\lceil L/16\rceil }, are:

ci=m[16i16]+28m[16i15]+216m[16i14]++2120m[16i1]+2128,{\displaystyle c_{i}=m[16i-16]+2^{8}m[16i-15]+2^{16}m[16i-14]+\cdots +2^{120}m[16i-1]+2^{128},}

with the exception that, ifL0(mod16){\displaystyle L\not \equiv 0{\pmod {16}}}, then:

cq=m[16q16]+28m[16q15]++28(Lmod16)8m[L1]+28(Lmod16).{\displaystyle c_{q}=m[16q-16]+2^{8}m[16q-15]+\cdots +2^{8(L{\bmod {1}}6)-8}m[L-1]+2^{8(L{\bmod {1}}6)}.}

The secret keyr=(r[0],r[1],r[2],,r[15]){\displaystyle r=(r[0],r[1],r[2],\dotsc ,r[15])} is restricted to have the bytesr[3],r[7],r[11],r[15]{0,1,2,,15}{\displaystyle r[3],r[7],r[11],r[15]\in \{0,1,2,\dotsc ,15\}},i.e., to have their top four bits clear; and to have the bytesr[4],r[8],r[12]{0,4,8,,252}{\displaystyle r[4],r[8],r[12]\in \{0,4,8,\dotsc ,252\}},i.e., to have their bottom two bits clear.Thus there are2106{\displaystyle 2^{106}} distinct possible values ofr{\displaystyle r}.

Use as a one-time authenticator

[edit]

Ifs{\displaystyle s} is a secret 16-byte string interpreted as a little-endian integer, then

a:=(Poly1305r(m)+s)mod2128{\displaystyle a:={\bigl (}\operatorname {Poly1305} _{r}(m)+s{\bigr )}{\bmod {2}}^{128}}

is called theauthenticator for the messagem{\displaystyle m}.If a sender and recipient share the 32-byte secret key(r,s){\displaystyle (r,s)} in advance, chosen uniformly at random, then the sender can transmit an authenticated message(a,m){\displaystyle (a,m)}.When the recipient receives analleged authenticated message(a,m){\displaystyle (a',m')} (which may have been modified in transmit by an adversary), they can verify its authenticity by testing whether

a=?(Poly1305r(m)+s)mod2128.{\displaystyle a'\mathrel {\stackrel {?}{=}} {\bigl (}\operatorname {Poly1305} _{r}(m')+s{\bigr )}{\bmod {2}}^{128}.}Without knowledge of(r,s){\displaystyle (r,s)}, the adversary has probability8L/16/2106{\displaystyle 8\lceil L/16\rceil /2^{106}} of finding any(a,m)(a,m){\displaystyle (a',m')\neq (a,m)} that will pass verification.

However, the same key(r,s){\displaystyle (r,s)} must not be reused for two messages.If the adversary learns

a1=(Poly1305r(m1)+s)mod2128,a2=(Poly1305r(m2)+s)mod2128,{\displaystyle {\begin{aligned}a_{1}&={\bigl (}\operatorname {Poly1305} _{r}(m_{1})+s{\bigr )}{\bmod {2}}^{128},\\a_{2}&={\bigl (}\operatorname {Poly1305} _{r}(m_{2})+s{\bigr )}{\bmod {2}}^{128},\end{aligned}}}

form1m2{\displaystyle m_{1}\neq m_{2}}, they can subtract

a1a2Poly1305r(m1)Poly1305r(m2)(mod2128){\displaystyle a_{1}-a_{2}\equiv \operatorname {Poly1305} _{r}(m_{1})-\operatorname {Poly1305} _{r}(m_{2}){\pmod {2^{128}}}}

and find a root of the resulting polynomial to recover a small list of candidates for the secret evaluation pointr{\displaystyle r}, and from that the secret pads{\displaystyle s}.The adversary can then use this to forge additional messages with high probability.

Use in Poly1305-AES as a Carter–Wegman authenticator

[edit]

The original Poly1305-AES proposal[2] uses the Carter–Wegman structure[4][5] to authenticate many messages by takingai:=Hr(mi)+pi{\displaystyle a_{i}:=H_{r}(m_{i})+p_{i}} to be the authenticator on theith messagemi{\displaystyle m_{i}}, whereHr{\displaystyle H_{r}} is a universal hash family andpi{\displaystyle p_{i}} is an independent uniform random hash value that serves as a one-time pad to conceal it.Poly1305-AES usesAES-128 to generatepi:=AESk(i){\displaystyle p_{i}:=\operatorname {AES} _{k}(i)}, wherei{\displaystyle i} is encoded as a 16-byte little-endian integer.

Specifically, a Poly1305-AES key is a 32-byte pair(r,k){\displaystyle (r,k)} of a 16-byte evaluation pointr{\displaystyle r}, as above, and a 16-byte AES keyk{\displaystyle k}.The Poly1305-AES authenticator on a messagemi{\displaystyle m_{i}} is

ai:=(Poly1305r(mi)+AESk(i))mod2128,{\displaystyle a_{i}:={\bigl (}\operatorname {Poly1305} _{r}(m_{i})+\operatorname {AES} _{k}(i){\bigr )}{\bmod {2}}^{128},}

where 16-byte strings and integers are identified by little-endian encoding.Note thatr{\displaystyle r} is reused between messages.

Without knowledge of(r,k){\displaystyle (r,k)}, the adversary has low probability of forging any authenticated messages that the recipient will accept as genuine.Suppose the adversary seesC{\displaystyle C} authenticated messages and attemptsD{\displaystyle D} forgeries, and candistinguishAESk{\displaystyle \operatorname {AES} _{k}} from a uniform random permutation with advantage at mostδ{\displaystyle \delta }.(Unless AES is broken,δ{\displaystyle \delta } is very small.)The adversary's chance of success at a single forgery is at most:

δ+(1C/2128)(C+1)/28DL/162106.{\displaystyle \delta +{\frac {(1-C/2^{128})^{-(C+1)/2}\cdot 8D\lceil L/16\rceil }{2^{106}}}.}

The message numberi{\displaystyle i} must never be repeated with the same key(r,k){\displaystyle (r,k)}.If it is, the adversary can recover a small list of candidates forr{\displaystyle r} andAESk(i){\displaystyle \operatorname {AES} _{k}(i)}, as with the one-time authenticator, and use that to forge messages.

Use in NaCl and ChaCha20-Poly1305

[edit]

TheNaCl crypto_secretbox_xsalsa20poly1305 authenticated cipher uses a message numberi{\displaystyle i} with theXSalsa20 stream cipher to generate a per-messagekey stream, the first 32 bytes of which are taken as a one-time Poly1305 key(ri,si){\displaystyle (r_{i},s_{i})} and the rest of which is used for encrypting the message.It then uses Poly1305 as a one-time authenticator for the ciphertext of the message.[6]ChaCha20-Poly1305 does the same but withChaCha instead ofXSalsa20.[8]XChaCha20-Poly1305 using XChaCha20 instead of XSalsa20 has also been described.[10]

Security

[edit]

The security of Poly1305 and its derivatives against forgery follows from itsbounded difference probability as auniversal hash family:Ifm1{\displaystyle m_{1}} andm2{\displaystyle m_{2}} are messages of up toL{\displaystyle L} bytes each, andd{\displaystyle d} is any 16-byte string interpreted as a little-endian integer, then

Pr[Poly1305r(m1)Poly1305r(m2)d(mod2128)]8L/162106,{\displaystyle \Pr[\operatorname {Poly1305} _{r}(m_{1})-\operatorname {Poly1305} _{r}(m_{2})\equiv d{\pmod {2^{128}}}]\leq {\frac {8\lceil L/16\rceil }{2^{106}}},}

wherer{\displaystyle r} is a uniform random Poly1305 key.[2]: Theorem 3.3, p. 8 

This property is sometimes calledϵ{\displaystyle \epsilon }-almost-Δ-universality overZ/2128Z{\displaystyle \mathbb {Z} /2^{128}\mathbb {Z} }, orϵ{\displaystyle \epsilon }-AΔU,[11]whereϵ=8L/16/2106{\displaystyle \epsilon =8\lceil L/16\rceil /2^{106}} in this case.

Of one-time authenticator

[edit]

With a one-time authenticatora=(Poly1305r(m)+s)mod2128{\displaystyle a={\bigl (}\operatorname {Poly1305} _{r}(m)+s{\bigr )}{\bmod {2}}^{128}}, the adversary's success probability for any forgery attempt(a,m){\displaystyle (a',m')} on a messagem{\displaystyle m'} of up toL{\displaystyle L} bytes is:

Pr[a=Poly1305r(m)+sa=Poly1305r(m)+s]=Pr[a=Poly1305r(m)+aPoly1305r(m)]=Pr[Poly1305r(m)Poly1305r(m)=aa]8L/16/2106.{\displaystyle {\begin{aligned}\Pr[&a'=\operatorname {Poly1305} _{r}(m')+s\mathrel {\mid } a=\operatorname {Poly1305} _{r}(m)+s]\\&=\Pr[a'=\operatorname {Poly1305} _{r}(m')+a-\operatorname {Poly1305} _{r}(m)]\\&=\Pr[\operatorname {Poly1305} _{r}(m')-\operatorname {Poly1305} _{r}(m)=a'-a]\\&\leq 8\lceil L/16\rceil /2^{106}.\end{aligned}}}

Here arithmetic inside thePr[]{\displaystyle \Pr[\cdots ]} is taken to be inZ/2128Z{\displaystyle \mathbb {Z} /2^{128}\mathbb {Z} } for simplicity.

Of NaCl and ChaCha20-Poly1305

[edit]

ForNaCl crypto_secretbox_xsalsa20poly1305 andChaCha20-Poly1305, the adversary's success probability at forgery is the same for each message independently as for a one-time authenticator, plus the adversary's distinguishing advantageδ{\displaystyle \delta } against XSalsa20 or ChaCha aspseudorandom functions used to generate the per-message key.In other words, the probability that the adversary succeeds at a single forgery afterD{\displaystyle D} attempts of messages up toL{\displaystyle L} bytes is at most:

δ+8DL/162106.{\displaystyle \delta +{\frac {8D\lceil L/16\rceil }{2^{106}}}.}

Of Poly1305-AES

[edit]

The security of Poly1305-AES against forgery follows from the Carter–Wegman–Shoup structure, which instantiates a Carter–Wegman authenticator with a permutation to generate the per-message pad.[12]If an adversary seesC{\displaystyle C} authenticated messages and attemptsD{\displaystyle D} forgeries of messages of up toL{\displaystyle L} bytes, and if the adversary has distinguishing advantage at mostδ{\displaystyle \delta } against AES-128 as apseudorandom permutation, then the probability the adversary succeeds at any one of theD{\displaystyle D} forgeries is at most:[2]

δ+(1C/2128)(C+1)/28DL/162106.{\displaystyle \delta +{\frac {(1-C/2^{128})^{-(C+1)/2}\cdot 8D\lceil L/16\rceil }{2^{106}}}.}

For instance, assuming that messages are packets up to 1024 bytes; that the attacker sees 264 messages authenticated under a Poly1305-AES key; that the attacker attempts a whopping 275 forgeries; and that the attacker cannot break AES with probability above δ; then, with probability at least 0.999999 − δ, all the 275 are rejected

— Bernstein, Daniel J. (2005)[2]

Speed

[edit]

Poly1305-AES can be computed at high speed in various CPUs: for ann-byte message, no more than 3.1n + 780 Athlon cycles are needed,[2] for example.The author has released optimizedsource code forAthlon,Pentium Pro/II/III/M,PowerPC, andUltraSPARC, in addition to non-optimizedreference implementations inC andC++ aspublic domain software.[13]

Implementations

[edit]

Below is a list of cryptography libraries that support Poly1305:

See also

[edit]
  • ChaCha20-Poly1305 – an AEAD scheme combining the stream cipher ChaCha20 with a variant of Poly1305

References

[edit]
  1. ^abcdAumasson, Jean-Philippe (2018). "Chapter 7: Keyed Hashing".Serious Cryptography: A Practical Introduction to Modern Encryption. No Starch Press. pp. 136–138.ISBN 978-1-59327-826-7.
  2. ^abcdefghBernstein, Daniel J. (2005-03-29)."The Poly1305-AES message-authentication code". In Gilbert, Henri; Handschuh, Helena (eds.).Fast Software Encryption: 12th international workshop. FSE 2005. Lecture Notes in Computer Science. Paris, France: Springer.doi:10.1007/11502760_3.ISBN 3-540-26541-4. Retrieved2022-10-14.
  3. ^Bernstein, Daniel J. (2008-05-01). "Protecting communications against forgery". In Buhler, Joe; Stevenhagen, Peter (eds.).Algorithmic number theory: lattices, number fields, curves and cryptography. Mathematical Sciences Research Institute Publications. Vol. 44. Cambridge University Press. pp. 535–549.ISBN 978-0521808545. Retrieved2022-10-14.
  4. ^abWegman, Mark N.; Carter, J. Lawrence (1981). "New Hash Functions and Their Use in Authentication and Set Equality".Journal of Computer and System Sciences.22 (3):265–279.doi:10.1016/0022-0000(81)90033-7.
  5. ^abBoneh, Dan;Shoup, Victor (January 2020).A Graduate Course in Applied Cryptography(PDF) (Version 0.5 ed.). §7.4 The Carter-Wegman MAC, pp. 262–269. Retrieved2022-10-14.
  6. ^abBernstein, Daniel J. (2009-03-10).Cryptography in NaCl (Technical report). Document ID: 1ae6a0ecef3073622426b3ee56260d34.
  7. ^Nir, Y.; Langley, A. (May 2015).ChaCha20 and Poly1305 for IETF Protocols.doi:10.17487/RFC7539.RFC7539.
  8. ^abNir, Y.; Langley, A. (June 2018).ChaCha20 and Poly1305 for IETF Protocols.doi:10.17487/RFC8439.RFC8439.
  9. ^Langley, A.; Chang, W.; Mavrogiannopoulos, N.; Strombergson, J.; Josefsson, S. (June 2016).ChaCha20-Poly1305 Cipher Suites for Transport Layer Security (TLS).doi:10.17487/RFC7905.RFC7905.
  10. ^Arciszewski, Scott (10 January 2020)."XChaCha: eXtended-nonce ChaCha and AEAD_XChaCha20_Poly1305 (Expired Internet-Draft)".Ietf Datatracker.
  11. ^Halevi, Shai;Krawczyk, Hugo. "MMH: Software Message Authentication in the Gbit/Second Rates". InBiham, Eli (ed.).Fast Software Encryption. FSE 1997. Lecture Notes in Computer Science. Springer.doi:10.1007/BFb0052345.ISBN 978-3-540-63247-4.
  12. ^Bernstein, Daniel J. (2005-02-27)."Stronger security bounds for Wegman-Carter-Shoup authenticators". In Cramer, Ronald (ed.).Advances in Cryptology—EUROCRYPT 2005, 24th annual international conference on the theory and applications of cryptographic techniques. EUROCRYPT 2005. Lecture Notes in Computer Science. Aarhus, Denmark: Springer.doi:10.1007/11426639_10.ISBN 3-540-25910-4.
  13. ^A state-of-the-art message-authentication code on cr.yp.to

External links

[edit]
Common functions
SHA-3 finalists
Other functions
Password hashing/
key stretching functions
General purpose
key derivation functions
MAC functions
Authenticated
encryption
modes
Attacks
Design
Standardization
Utilization
General
Mathematics
Retrieved from "https://en.wikipedia.org/w/index.php?title=Poly1305&oldid=1276596053"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp