Out of Band Authorization Code Delivery for OAuth 2.0
draft-richer-oauth-oob-authcode-01
This document is an Internet-Draft (I-D).
Anyone may submit an I-D to the IETF.
This I-D is not endorsed by the IETF and has no formal standing in the
IETF standards process.
| Document | Type | Active Internet-Draft (individual) | |
|---|---|---|---|
| Author | Justin Richer | ||
| Last updated | 2026-12-04 | ||
| RFC stream | (None) | ||
| Intended RFC status | (None) | ||
| Formats | |||
| Stream | Stream state | (No stream defined) | |
| Consensus boilerplate | Unknown | ||
| RFC Editor Note | (None) | ||
| IESG | IESG state | I-D Exists | |
| Telechat date | (None) | ||
| Responsible AD | (None) | ||
| Send notices to | (None) |
draft-richer-oauth-oob-authcode-01
Web Authorization Protocol J. Richer
Internet-Draft MongoDB
Intended status: Informational 4 December 2026
Expires: 7 June 2027
Out of Band Authorization Code Delivery for OAuth 2.0
draft-richer-oauth-oob-authcode-01
Abstract
This client-side process allows clients to use the authorization code
grant type without the ability to host the redirect_uri themselves.
This process creates a single copyable value that the resource owner
can copy from a simple helper page into the waiting client
application.
About This Document
This note is to be removed before publishing as an RFC.
The latest revision of this draft can be found at
https://jricher.github.io/draft-richer-oauth-oob-authcode/draft-
richer-oauth-oob-authcode.html. Status information for this document
may be found at https://datatracker.ietf.org/doc/draft-richer-oauth-
oob-authcode/.
Discussion of this document takes place on the Web Authorization
Protocol Working Group mailing list (mailto:oauth@ietf.org), which is
archived at https://mailarchive.ietf.org/arch/browse/oauth/.
Subscribe at https://www.ietf.org/mailman/listinfo/oauth/.
Source for this draft and an issue tracker can be found at
https://github.com/jricher/draft-richer-oauth-oob-authcode.
Status of This Memo
This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/.
Richer Expires 7 June 2027 [Page 1]
Internet-Draft OOB Auth Codes December 2026
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
This Internet-Draft will expire on 7 June 2027.
Copyright Notice
Copyright (c) 2026 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents (https://trustee.ietf.org/
license-info) in effect on the date of publication of this document.
Please review these documents carefully, as they describe your rights
and restrictions with respect to this document. Code Components
extracted from this document must include Revised BSD License text as
described in Section 4.e of the Trust Legal Provisions and are
provided without warranty as described in the Revised BSD License.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1. Terminology . . . . . . . . . . . . . . . . . . . . . . . 3
2. Out of Band Authorization Code Transfer . . . . . . . . . . . 3
2.1. Structure of the Combined Code . . . . . . . . . . . . . 5
2.2. Creating the Combined Code . . . . . . . . . . . . . . . 6
2.3. Processing the Combined Code . . . . . . . . . . . . . . 7
3. Limitations and Implementation Considerations . . . . . . . . 8
3.1. Helper Page . . . . . . . . . . . . . . . . . . . . . . . 9
3.2. Stateless Clients . . . . . . . . . . . . . . . . . . . . 9
3.3. Fall-through For Static Pages . . . . . . . . . . . . . . 9
3.4. Parsing the Version . . . . . . . . . . . . . . . . . . . 9
4. Security Considerations . . . . . . . . . . . . . . . . . . . 10
4.1. PKCE Is Required . . . . . . . . . . . . . . . . . . . . 10
4.2. Security Comparison to the Device Grant . . . . . . . . . 10
5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 11
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 11
References . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Normative References . . . . . . . . . . . . . . . . . . . . . 11
Informative References . . . . . . . . . . . . . . . . . . . . 12
Appendix A. Example Implementations . . . . . . . . . . . . . . 12
A.1. Combined Code Creation . . . . . . . . . . . . . . . . . 12
A.2. Combined Code Validation . . . . . . . . . . . . . . . . 13
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 15
Richer Expires 7 June 2027 [Page 2]
Internet-Draft OOB Auth Codes December 2026
1. Introduction
The OAuth authorization code grant type defined in [OAUTH] relies on
the front-channel to communicate parameters between the client and
authorization server (AS) using query parameters. This process
relies on the resource owner's browser being able to launch a URI
that is hosted on each of the AS and the client.
In some circumstances, such as a command line client running on a
remote terminal, the resource owner's browser cannot reach a URL
hosted by the client. These kinds of clients have traditionally used
alternatives such as the device code grant type [DEVICECODE], but the
split between different grant types depending on where the client is
running is a complication that requires server-side support, multiple
network roundtrips (with polling), and potentially multiple different
client registrations.
Instead of using a different grant type, an out-of-band mechanism,
such as the resource owner copying and pasting values into the
waiting client, to deliver the authorization code and state value
from the AS to the client. This process can be error prone as
multiple separate values need to be transferred intact to the client
without having their values conflated with each other.
This specification defines a method to harden the out-of-band
delivery of the code and state parameters to the client to be a
single value that is less error-prone. No changes or participation
by the AS is required (apart from a valid redirect_uri for the helper
page).
1.1. Terminology
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in
BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all
capitals, as shown here.
2. Out of Band Authorization Code Transfer
Richer Expires 7 June 2027 [Page 3]
Internet-Draft OOB Auth Codes December 2026
+---------+ +---------+ +---------+ +---------+ +---------+
| User | | Client | | AS | | Browser | | Helper |
+---------+ +---------+ +---------+ +---------+ +---------+
| | | | |
| |--(1)------>| | |
| | | | |
| |--(2)------------------->| |
| | | | |
| | |<-(3)-------| |
| | | | |
| | |--(4)------>| |
| | | | |
| | | |--(5)------>|
| | | | |
| | | | |--+
| | | | | | (6)
| | | | |<-+
| | | | |
|<-(7)----------------------------------------------|
| | | | |
|--(8)------>| | | |
| | | | |
| |--+ | | |
| | | (9) | | |
| |<-+ | | |
| | | | |
| |--(10)----->| | |
| | | | |
1. The client registers its helper page https://c.example.com/
callback as a valid redirect_uri
2. The client creates a state value and sends it with other
parameters to the browser as part of the request to the
authorization URI; the client waits for a paste input
3. The browser fetches the authorization URI at the AS
4. The AS completes the OAuth transaction and creates a code value
and sends this to the browser as part of the callback
5. The browser fetches the helper page with the code and state
parameters
6. The helper page parses the code and state parameters in
javascript and calculates the combined code using HKDF in
Section 2.2
Richer Expires 7 June 2027 [Page 4]
Internet-Draft OOB Auth Codes December 2026
7. The user copies the combined code from the helper page
8. The user pastes the combined code into the client
9. The client uses its stored state value to derive the code value
from the combined code in Section 2.3
10. The client presents the derived code value to the token endpoint
for an access token, along with other parameters
Throughout this process, the client and AS need not have previously
agreed on any shared secrets or encodings. The client does not start
an HTTP server and does not receive the call to the redirect URI,
instead relying on interactive input from the resource owner to
deliver the response code.
The client MUST use [PKCE] with the authorization code to protect
against pasted code injection. This specification MUST NOT be used
with any other grant type.
2.1. Structure of the Combined Code
The combined code is the bytewise XOR combination of the code value
and the HKDF output of the client's state value, along with a
prepended version flag and checksum.
The version flag is encoded in the highest bits of the prefix and
defines the length of the checksum and the meaning of any leading
flag bits. This specification defines the behavior of value 0 (zero)
and reserves 1 (one) for future use.
With version bit 0 (zero) there is a single bit flag to control the
value of the INFO parameter of the HKDF calculation. This
specification defines two options:
* 0: The value of the iss parameter
* 1: The fixed value oauth-out-of-band-authorization-code
It is RECOMMENDED that compliant systems always require use of the
iss parameter as in [OAUTH21].
Richer Expires 7 June 2027 [Page 5]
Internet-Draft OOB Auth Codes December 2026
2.2. Creating the Combined Code
The helper page calculates and encodes the combined code based on the
input parameters in the response from the authorization endpoint.
The state and code values are combined using a HKDF function [HKDF]
and a bytewise XOR. A prefix containing the version flag and
checksum are prepended to the output.
If the iss parameter is included, the helper page MUST use it as the
INFO. If the iss parameter is not included, the fixed value oauth-
out-of-band-authorization-code is used instead.
0. INPUTS: code, state, iss
1. C = UTF8(code)
2. INFO = IF NONEMPTY(iss) : UTF8(iss)
ELSE: "oauth-out-of-band-authorization-code"
3. K = HKDF(ikm = UTF8(state),
salt = "" (zero-length),
info = INFO,
L = len(C)) ; always the same length as C
4. E = C ^ K ; bytewise XOR
5. S = SHA256(C)[0..2] & 0x3FFFFF; bitwise AND 22-bit checksum
6. F = IF NONEMPTY(iss): 0b00 ; 2-bit binary value
ELSE: 0b01 ; 2-bit binary value
7. P = ( F << 22 ) | S ; bitshift and bitwise OR
8. CC = B64Uenc(P) || B64Uenc(E) ; concatenate the checksum
1. Translate the code to UTF8 bytes C. Since the authorization code
is ASCII per [OAUTH], no additional encoding is needed for valid
inputs.
2. Determine the INFO value based on whether the iss value is
present on the page as described in Section 2.1.
3. Create a derived key K using the state value and INFO, the result
that is exactly the same length as C.
4. The code value C and the HKDF output K are XORed together,
bytewise, to create an encoded value E.
5. Create a checksum S by hashing the code value C with [SHA256],
extract the first 3 bytes, and mask to 22 bits.
6. The version flag F is determined based on whether the iss value
is present (therefore signalling the value of INFO to the client)
as described in Section 2.1.
Richer Expires 7 June 2027 [Page 6]
Internet-Draft OOB Auth Codes December 2026
7. The prefix P places the two bits of the version flag F in the
high bit positions of the 3 bytes holding the 22-bit checksum S
using a left bitshift on the version and a bitwise OR against the
checksum S.
8. The combined code CC is the concatenated prefix from (7) and the
encoded value E from (4), both separately base64 URL encoded
(with no padding). [BASE64]
The helper page MUST display the combined code value to the user
after calculation, and MUST direct the user to enter the code exactly
as is to their waiting client. If the helper page cannot process the
combined code, it MUST instruct the user to use a fall-through
mechanism described in Section 3.3.
2.3. Processing the Combined Code
When the client receives the combined code, it uses its state value
and extracts the code value for use at the AS. If the client knows
the issuer value of the AS from discovery or configuration, it uses
that as iss below. If the client does not know this value, all
operations using iss below fail.
1. V = B64Udec(CC[0..1]) >> 7 ; decode the first byte and bitshift to get the version
2. IF V != 0 : FAIL ; only version 0 defined in this spec
3. P = B64Udec(CC[0..3]) ; checksum and info flag (3 bytes total)
4. I = P >> 22 ; bitshift, I is guaranteed to be 0b00 or 0b01
5. INFO = IF I == 0: UTF8(iss)
ELSE: "oauth-out-of-band-authorization-code"
6. E = B64Udec(CC[4...]) ; decode the remainder of the combined code string
7. K = HKDF(ikm = UTF8(state),
salt = "" (zero-length),
info = INFO,
L = len(E))
8. C = E ^ K ; bytewise XOR
9. S = SHA256(C)[0..2] & 0x3FFFFF ; calculated actual checksum, masked to 22 bits
10. X = P & 0x3FFFFF ; bitwise AND, expected checksum, masked to 22 bits
11. If S != X: FAIL
1. Extract the first bit of the decoded combined code as the
version marker V. Note that base64 works on bytes so here we're
treating the first two characters as containing one byte plus 4
nonzero pad bits. See discussion and alternatives in
Section 3.4.
2. If the version marker V is anything other than '0', fail.
Future versions would branch here instead of failing.
Richer Expires 7 June 2027 [Page 7]
Internet-Draft OOB Auth Codes December 2026
3. Extract the prefix of 3 bytes decoded total.
4. Extract the info flag I with a right bitshift. Since the high
bit is '0', this value is guaranteed to be either '0' or '1' and
nothing else.
5. The INFO value is determined based on the value of the I flag as
described in Section 2.1.
6. Decode the remainder of the string into a byte array
representing the encoded value E.
7. Create the derived key K using the HKDF function based on the
state value and INFO, the result is exactly the same length as
the encoded value E.
8. XOR the encoded combined code E and the HKDF output K, bytewise,
to extract the code value C.
9. Calculate a 3-byte checksum S by hashing the extracted code
value with [SHA256], extract the first 3 bytes, and mask to 22
bits.
10. Mask the decoded prefix P from (3) to 22 bits to extract the
checksum sent over the wire.
11. If the checksum against the extracted code doesn't match the
checksum sent over the wire, fail.
Any combined codes equal to or fewer than the checksum length (4
characters / 3 decoded bytes in this version) MUST be discarded.
If the client expects the iss field to be sent by the AS through
configuration or discovery, and the I value indicates that it was not
used to create the combined code, the client MUST reject the request.
The client then uses the code value in its request to the token
endpoint.
If the state value doesn't match, the key derivation will produce the
wrong K leading to the wrong C (code), and the token request will
fail.
3. Limitations and Implementation Considerations
Richer Expires 7 June 2027 [Page 8]
Internet-Draft OOB Auth Codes December 2026
3.1. Helper Page
The helper page is designed to be a statically hosted page with no
backend processing and no state. Consequently, any person (or
attacker) could use the same page to create combined codes using this
algorithm by providing arbitrary code and state values. As such, the
use of this does not protect clients from theft of code and state
values.
3.2. Stateless Clients
In order to use this, a client needs to know its state value at the
time the request comes in. Stateless clients that depend on the
state value to bootstrap the request won't be able to extract the
code value from a combined code and shouldn't use this method.
3.3. Fall-through For Static Pages
If the helper page is unable to process the HKDF calculation, such as
JavaScript being disabled, the helper page SHOULD tell the user as
much.
To support such cases, the client SHOULD additionally support the
user copying and pasting the entire helper page URL, with parameters,
and extracting the code and state values directly, just as if the
client had served the URL itself. For this case, there is no use of
the HKDF to create a combined code.
3.4. Parsing the Version
In practical terms, the version flag can be detected without decoding
the incoming string by looking at the first raw base64 encoded
character.
+==============+==================+=================+
| Version flag | INFO flag | First character |
+==============+==================+=================+
| 0 | 0 (iss) | A–P |
+--------------+------------------+-----------------+
| 0 | 1 (fixed string) | Q–Z, a–f |
+--------------+------------------+-----------------+
| 1 | N/A (reserved) | g–z, 0–9, -, _ |
+--------------+------------------+-----------------+
Table 1
The decoding algorithm can then alternatively be implemented as
Richer Expires 7 June 2027 [Page 9]
Internet-Draft OOB Auth Codes December 2026
1. F = CC[0] ; flag character
2. IF F != [A-Za-f]: FAIL ; only version 0 defined in this spec
3. P = B64Udec(CC[0..3]) ; checksum and info flag (3 bytes total)
4+5. INFO = IF F == [A-P]: UTF8(iss)
ELSE: "oauth-out-of-band-authorization-code"
(continue at step 6 above)
4. Security Considerations
This process provides no additional security protections beyond that
already provided by the basic authorization code grant. While
cryptographic functions are used, the code value is still passed in
the browser during the first steps and is not kept secret.
The code and state values are passed to whatever server, CDN, or
system serves the static helper page, including its mirrors and
caches, as part of the HTTP GET request.
The state value now needs to be cryptographically random enough to
support the HKDF, and at the very least needs to be unique per
request. Two identical (or guessable) state values could decode
different codes on different requests.
4.1. PKCE Is Required
In order to prevent injection of an unrelated authorization code into
a waiting client, the client has to use [PKCE] in its request.
4.2. Security Comparison to the Device Grant
The OAuth Device Grant [DEVICECODE] also provides a way for a
resource owner to deliver a code between two separate devices and
complete an OAuth transaction. However, in the device grant, the
client releases control over the shared code (the user code) and can
only detect that someone used it at the authorization server. This
aspect makes the device grant inherently phishable as described in
[CROSSDEVICE].
The authorization code, on the other hand, is protected by PKCE. A
waiting client needs to have created the code verifier and sent the
associated code challenge with its original request. Injecting an
authorization code other than the one that's in response to the
request at hand will be rejected by the authorization server, even if
the delivery mechanism is compromised.
Richer Expires 7 June 2027 [Page 10]
Internet-Draft OOB Auth Codes December 2026
5. IANA Considerations
This document has no IANA actions.
Acknowledgments
Thank you to Jeff Lombardo and Pieter Kasselman for an early review
of this work. Thank you to Luke Sanderson for implementation and
deployment review.
References
Normative References
[BASE64] Josefsson, S., "The Base16, Base32, and Base64 Data
Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006,
<https://www.rfc-editor.org/rfc/rfc4648>.
[HKDF] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand
Key Derivation Function (HKDF)", RFC 5869,
DOI 10.17487/RFC5869, May 2010,
<https://www.rfc-editor.org/rfc/rfc5869>.
[OAUTH] Hardt, D., Ed., "The OAuth 2.0 Authorization Framework",
RFC 6749, DOI 10.17487/RFC6749, October 2012,
<https://www.rfc-editor.org/rfc/rfc6749>.
[OAUTH21] Hardt, D., Parecki, A., and T. Lodderstedt, "The OAuth 2.1
Authorization Framework", Work in Progress, Internet-
Draft, draft-ietf-oauth-v2-1-17, 30 October 2026,
<https://datatracker.ietf.org/doc/html/draft-ietf-oauth-
v2-1-17>.
[PKCE] Sakimura, N., Ed., Bradley, J., and N. Agarwal, "Proof Key
for Code Exchange by OAuth Public Clients", RFC 7636,
DOI 10.17487/RFC7636, September 2015,
<https://www.rfc-editor.org/rfc/rfc7636>.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119,
DOI 10.17487/RFC2119, March 1997,
<https://www.rfc-editor.org/rfc/rfc2119>.
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
May 2017, <https://www.rfc-editor.org/rfc/rfc8174>.
Richer Expires 7 June 2027 [Page 11]
Internet-Draft OOB Auth Codes December 2026
[SHA256] Eastlake 3rd, D. and T. Hansen, "US Secure Hash Algorithms
(SHA and SHA-based HMAC and HKDF)", RFC 6234,
DOI 10.17487/RFC6234, May 2011,
<https://www.rfc-editor.org/rfc/rfc6234>.
Informative References
[CROSSDEVICE]
Kasselman, P., Fett, D., and F. Skokan, "Best Current
Practice for Security of Cross-Device Flows", BCP 247,
RFC 10027, DOI 10.17487/RFC10027, August 2026,
<https://www.rfc-editor.org/rfc/rfc10027>.
[DEVICECODE]
Denniss, W., Bradley, J., Jones, M., and H. Tschofenig,
"OAuth 2.0 Device Authorization Grant", RFC 8628,
DOI 10.17487/RFC8628, August 2019,
<https://www.rfc-editor.org/rfc/rfc8628>.
Appendix A. Example Implementations
A.1. Combined Code Creation
A JavaScript implementation of the generation algorithm in
Section 2.2. b64uenc is a Base64 URL encoder with no padding (not
included here). The inputs (expected to be taken from the query
arguments) are as follows:
code The authorization code issued from the AS
state The state value echoed by the AS
iss The issuer value sent by the AS, or null (or empty) if not
present
Richer Expires 7 June 2027 [Page 12]
Internet-Draft OOB Auth Codes December 2026
const FIXED_INFO = "oauth-out-of-band-authorization-code";
async function createCombinedCode(code, state, iss) {
const utf8 = new TextEncoder();
// 1. C = UTF8(code)
const c = utf8.encode(code);
// 2. INFO = IF NONEMPTY(iss): UTF8(iss) ELSE: fixed value
const info = iss ? utf8.encode(iss) : utf8.encode(FIXED_INFO);
// 3. K = HKDF(ikm = UTF8(state), salt = "", info = INFO, L = len(C))
const ikm = await crypto.subtle.importKey("raw", utf8.encode(state), "HKDF", false, ["deriveBits"]);
const k = new Uint8Array(await crypto.subtle.deriveBits(
{ name: "HKDF", hash: "SHA-256", salt: new Uint8Array(0), info: info },
ikm, c.length * 8));
// 4. E = C ^ K
const e = c.map((b, i) => b ^ k[i]);
// 5. S = SHA256(C)[0..2] & 0x3FFFFF
const h = new Uint8Array(await crypto.subtle.digest("SHA-256", c));
const s = ((h[0] << 16) | (h[1] << 8) | h[2]) & 0x3FFFFF;
// 6. F = IF NONEMPTY(iss): 0b00 ELSE: 0b01
const f = iss ? 0b00 : 0b01;
// 7. P = (F << 22) | S
const p = (f << 22) | s;
// 8. CC = B64Uenc(P) || B64Uenc(E)
const prefix = new Uint8Array([(p >> 16) & 0xFF, (p >> 8) & 0xFF, p & 0xFF]);
return b64uenc(prefix) + b64uenc(e);
}
A.2. Combined Code Validation
A Go implementation of the validation algorithm in Section 2.3, using
the version detection method in Section 3.4. The inputs are as
follows:
cc The combined code, pasted in by the user
state The state value remembered from the authorization request
issuer The expected value of the issuer expected to be returned, or
empty if the issuer is not expected to be returned
Richer Expires 7 June 2027 [Page 13]
Internet-Draft OOB Auth Codes December 2026
The output is the code to be sent to the token endpoint or an error.
package oobcode
import (
"crypto/hkdf"
"crypto/sha256"
"encoding/base64"
"errors"
)
const fixedInfo = "oauth-out-of-band-authorization-code"
var b64u = base64.RawURLEncoding
func ProcessCombinedCode(cc, state, issuer string) (string, error) {
if len(cc) <= 4 {
return "", errors.New("combined code too short")
}
// 1. F = CC[0]
f := cc[0]
// 2. IF F != [A-Za-f]: FAIL
versFlag := f >= 'A' && f <= 'Z' || f >= 'a' && f <= 'f'
if !versFlag {
return "", errors.New("unsupported version")
}
// 3. P = B64Udec(CC[0..3])
pb, err := b64u.DecodeString(cc[0:4])
if err != nil {
return "", err
}
p := uint32(pb[0])<<16 | uint32(pb[1])<<8 | uint32(pb[2])
// 4+5. INFO = IF F == [A-P]: UTF8(iss) ELSE: fixed value
issFlag := f >= 'A' && f <= 'P'
var info string
if issFlag {
if issuer == "" {
return "", errors.New("issuer required but unknown")
}
info = issuer
} else {
if issuer != "" {
return "", errors.New("issuer expected but not used")
}
Richer Expires 7 June 2027 [Page 14]
Internet-Draft OOB Auth Codes December 2026
info = fixedInfo
}
// 6. E = B64Udec(CC[4...])
e, err := b64u.DecodeString(cc[4:])
if err != nil {
return "", err
}
// 7. K = HKDF(ikm = UTF8(state), salt = "", info = INFO, L = len(E))
k, err := hkdf.Key(sha256.New, []byte(state), nil, info, len(e))
if err != nil {
return "", err
}
// 8. C = E ^ K
c := make([]byte, len(e))
for n := range e {
c[n] = e[n] ^ k[n]
}
// 9. S = SHA256(C)[0..2] & 0x3FFFFF
h := sha256.Sum256(c)
s := (uint32(h[0])<<16 | uint32(h[1])<<8 | uint32(h[2])) & 0x3FFFFF
// 10. X = P & 0x3FFFFF
x := p & 0x3FFFFF
// 11. If S != X: FAIL
if s != x {
return "", errors.New("checksum mismatch")
}
return string(c), nil
}
Author's Address
Justin Richer
MongoDB
Email: ietf@justin.richer.org
Richer Expires 7 June 2027 [Page 15]