CINXE.COM
device/fido/pin_internal.cc - chromium/src - Git at Google
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>device/fido/pin_internal.cc - chromium/src - Git at Google</title><link rel="stylesheet" type="text/css" href="/+static/base.css"><link rel="stylesheet" type="text/css" href="/+static/prettify/prettify.css"><!-- default customHeadTagPart --></head><body class="Site"><header class="Site-header"><div class="Header"><a class="Header-image" href="/"><img src="//www.gstatic.com/images/branding/lockups/2x/lockup_git_color_108x24dp.png" width="108" height="24" alt="Google Git"></a><div class="Header-menu"> <a class="Header-menuItem" href="https://accounts.google.com/AccountChooser?faa=1&service=gerritcodereview&continue=https://chromium.googlesource.com/login/chromium/src/%2B/refs/tags/130.0.6723.141/device/fido/pin_internal.cc">Sign in</a> </div></div></header><div class="Site-content"><div class="Container "><div class="Breadcrumbs"><a class="Breadcrumbs-crumb" href="/?format=HTML">chromium</a> / <a class="Breadcrumbs-crumb" href="/chromium/">chromium</a> / <a class="Breadcrumbs-crumb" href="/chromium/src/">src</a> / <a class="Breadcrumbs-crumb" href="/chromium/src/+/refs/tags/130.0.6723.141">refs/tags/130.0.6723.141</a> / <a class="Breadcrumbs-crumb" href="/chromium/src/+/refs/tags/130.0.6723.141/">.</a> / <a class="Breadcrumbs-crumb" href="/chromium/src/+/refs/tags/130.0.6723.141/device">device</a> / <a class="Breadcrumbs-crumb" href="/chromium/src/+/refs/tags/130.0.6723.141/device/fido">fido</a> / <span class="Breadcrumbs-crumb">pin_internal.cc</span></div><div class="u-sha1 u-monospace BlobSha1">blob: ba6aff600d7c89e33befc012a9ad4884da5f9652 [<a href="/chromium/src/+/refs/tags/130.0.6723.141/device/fido/pin_internal.cc">file</a>] [<a href="/chromium/src/+log/refs/tags/130.0.6723.141/device/fido/pin_internal.cc">log</a>] [<a href="/chromium/src/+blame/refs/tags/130.0.6723.141/device/fido/pin_internal.cc">blame</a>]</div><table class="FileContents"><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="1"></td><td class="FileContents-lineContents" id="1"><span class="com">// Copyright 2019 The Chromium Authors</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="2"></td><td class="FileContents-lineContents" id="2"><span class="com">// Use of this source code is governed by a BSD-style license that can be</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="3"></td><td class="FileContents-lineContents" id="3"><span class="com">// found in the LICENSE file.</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="4"></td><td class="FileContents-lineContents" id="4"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="5"></td><td class="FileContents-lineContents" id="5"><span class="com">#ifdef</span><span class="pln"> UNSAFE_BUFFERS_BUILD</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="6"></td><td class="FileContents-lineContents" id="6"><span class="com">// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="7"></td><td class="FileContents-lineContents" id="7"><span class="com">#pragma</span><span class="pln"> allow_unsafe_buffers</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="8"></td><td class="FileContents-lineContents" id="8"><span class="com">#endif</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="9"></td><td class="FileContents-lineContents" id="9"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="10"></td><td class="FileContents-lineContents" id="10"><span class="com">#include</span><span class="pln"> </span><span class="str">"device/fido/pin_internal.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="11"></td><td class="FileContents-lineContents" id="11"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="12"></td><td class="FileContents-lineContents" id="12"><span class="com">#include</span><span class="pln"> </span><span class="str"><string></span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="13"></td><td class="FileContents-lineContents" id="13"><span class="com">#include</span><span class="pln"> </span><span class="str"><utility></span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="14"></td><td class="FileContents-lineContents" id="14"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="15"></td><td class="FileContents-lineContents" id="15"><span class="com">#include</span><span class="pln"> </span><span class="str">"base/i18n/char_iterator.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="16"></td><td class="FileContents-lineContents" id="16"><span class="com">#include</span><span class="pln"> </span><span class="str">"base/no_destructor.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="17"></td><td class="FileContents-lineContents" id="17"><span class="com">#include</span><span class="pln"> </span><span class="str">"base/strings/string_util.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="18"></td><td class="FileContents-lineContents" id="18"><span class="com">#include</span><span class="pln"> </span><span class="str">"crypto/random.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="19"></td><td class="FileContents-lineContents" id="19"><span class="com">#include</span><span class="pln"> </span><span class="str">"third_party/boringssl/src/include/openssl/aes.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="20"></td><td class="FileContents-lineContents" id="20"><span class="com">#include</span><span class="pln"> </span><span class="str">"third_party/boringssl/src/include/openssl/bn.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="21"></td><td class="FileContents-lineContents" id="21"><span class="com">#include</span><span class="pln"> </span><span class="str">"third_party/boringssl/src/include/openssl/ec.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="22"></td><td class="FileContents-lineContents" id="22"><span class="com">#include</span><span class="pln"> </span><span class="str">"third_party/boringssl/src/include/openssl/ec_key.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="23"></td><td class="FileContents-lineContents" id="23"><span class="com">#include</span><span class="pln"> </span><span class="str">"third_party/boringssl/src/include/openssl/ecdh.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="24"></td><td class="FileContents-lineContents" id="24"><span class="com">#include</span><span class="pln"> </span><span class="str">"third_party/boringssl/src/include/openssl/evp.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="25"></td><td class="FileContents-lineContents" id="25"><span class="com">#include</span><span class="pln"> </span><span class="str">"third_party/boringssl/src/include/openssl/hkdf.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="26"></td><td class="FileContents-lineContents" id="26"><span class="com">#include</span><span class="pln"> </span><span class="str">"third_party/boringssl/src/include/openssl/hmac.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="27"></td><td class="FileContents-lineContents" id="27"><span class="com">#include</span><span class="pln"> </span><span class="str">"third_party/boringssl/src/include/openssl/mem.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="28"></td><td class="FileContents-lineContents" id="28"><span class="com">#include</span><span class="pln"> </span><span class="str">"third_party/boringssl/src/include/openssl/sha.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="29"></td><td class="FileContents-lineContents" id="29"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="30"></td><td class="FileContents-lineContents" id="30"><span class="kwd">namespace</span><span class="pln"> device </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="31"></td><td class="FileContents-lineContents" id="31"><span class="kwd">namespace</span><span class="pln"> pin </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="32"></td><td class="FileContents-lineContents" id="32"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="33"></td><td class="FileContents-lineContents" id="33"><span class="pln">std</span><span class="pun">::</span><span class="pln">optional</span><span class="pun"><</span><span class="pln">bssl</span><span class="pun">::</span><span class="typ">UniquePtr</span><span class="pun"><</span><span class="pln">EC_POINT</span><span class="pun">>></span><span class="pln"> </span><span class="typ">PointFromKeyAgreementResponse</span><span class="pun">(</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="34"></td><td class="FileContents-lineContents" id="34"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> EC_GROUP</span><span class="pun">*</span><span class="pln"> group</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="35"></td><td class="FileContents-lineContents" id="35"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> </span><span class="typ">KeyAgreementResponse</span><span class="pun">&</span><span class="pln"> response</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="36"></td><td class="FileContents-lineContents" id="36"><span class="pln"> bssl</span><span class="pun">::</span><span class="typ">UniquePtr</span><span class="pun"><</span><span class="pln">EC_POINT</span><span class="pun">></span><span class="pln"> ret</span><span class="pun">(</span><span class="pln">EC_POINT_new</span><span class="pun">(</span><span class="pln">group</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="37"></td><td class="FileContents-lineContents" id="37"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="38"></td><td class="FileContents-lineContents" id="38"><span class="pln"> bssl</span><span class="pun">::</span><span class="typ">UniquePtr</span><span class="pun"><</span><span class="pln">BIGNUM</span><span class="pun">></span><span class="pln"> x_bn</span><span class="pun">(</span><span class="pln">BN_new</span><span class="pun">()),</span><span class="pln"> y_bn</span><span class="pun">(</span><span class="pln">BN_new</span><span class="pun">());</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="39"></td><td class="FileContents-lineContents" id="39"><span class="pln"> BN_bin2bn</span><span class="pun">(</span><span class="pln">response</span><span class="pun">.</span><span class="pln">x</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">sizeof</span><span class="pun">(</span><span class="pln">response</span><span class="pun">.</span><span class="pln">x</span><span class="pun">),</span><span class="pln"> x_bn</span><span class="pun">.</span><span class="pln">get</span><span class="pun">());</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="40"></td><td class="FileContents-lineContents" id="40"><span class="pln"> BN_bin2bn</span><span class="pun">(</span><span class="pln">response</span><span class="pun">.</span><span class="pln">y</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">sizeof</span><span class="pun">(</span><span class="pln">response</span><span class="pun">.</span><span class="pln">y</span><span class="pun">),</span><span class="pln"> y_bn</span><span class="pun">.</span><span class="pln">get</span><span class="pun">());</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="41"></td><td class="FileContents-lineContents" id="41"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> </span><span class="kwd">bool</span><span class="pln"> on_curve </span><span class="pun">=</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="42"></td><td class="FileContents-lineContents" id="42"><span class="pln"> EC_POINT_set_affine_coordinates_GFp</span><span class="pun">(</span><span class="pln">group</span><span class="pun">,</span><span class="pln"> ret</span><span class="pun">.</span><span class="pln">get</span><span class="pun">(),</span><span class="pln"> x_bn</span><span class="pun">.</span><span class="pln">get</span><span class="pun">(),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="43"></td><td class="FileContents-lineContents" id="43"><span class="pln"> y_bn</span><span class="pun">.</span><span class="pln">get</span><span class="pun">(),</span><span class="pln"> </span><span class="kwd">nullptr</span><span class="pln"> </span><span class="com">/* ctx */</span><span class="pun">)</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> </span><span class="lit">1</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="44"></td><td class="FileContents-lineContents" id="44"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="45"></td><td class="FileContents-lineContents" id="45"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(!</span><span class="pln">on_curve</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="46"></td><td class="FileContents-lineContents" id="46"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> std</span><span class="pun">::</span><span class="pln">nullopt</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="47"></td><td class="FileContents-lineContents" id="47"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="48"></td><td class="FileContents-lineContents" id="48"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="49"></td><td class="FileContents-lineContents" id="49"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> ret</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="50"></td><td class="FileContents-lineContents" id="50"><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="51"></td><td class="FileContents-lineContents" id="51"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="52"></td><td class="FileContents-lineContents" id="52"><span class="com">// ProtocolV1 implements CTAP2.1 PIN/UV Auth Protocol One (6.5.10).</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="53"></td><td class="FileContents-lineContents" id="53"><span class="kwd">class</span><span class="pln"> </span><span class="typ">ProtocolV1</span><span class="pln"> </span><span class="pun">:</span><span class="pln"> </span><span class="kwd">public</span><span class="pln"> </span><span class="typ">Protocol</span><span class="pln"> </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="54"></td><td class="FileContents-lineContents" id="54"><span class="pln"> </span><span class="kwd">private</span><span class="pun">:</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="55"></td><td class="FileContents-lineContents" id="55"><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">constexpr</span><span class="pln"> </span><span class="typ">size_t</span><span class="pln"> kSharedKeySize </span><span class="pun">=</span><span class="pln"> </span><span class="lit">32u</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="56"></td><td class="FileContents-lineContents" id="56"><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">constexpr</span><span class="pln"> </span><span class="typ">size_t</span><span class="pln"> kSignatureSize </span><span class="pun">=</span><span class="pln"> </span><span class="lit">16u</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="57"></td><td class="FileContents-lineContents" id="57"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="58"></td><td class="FileContents-lineContents" id="58"><span class="pln"> std</span><span class="pun">::</span><span class="pln">array</span><span class="pun"><</span><span class="typ">uint8_t</span><span class="pun">,</span><span class="pln"> kP256X962Length</span><span class="pun">></span><span class="pln"> </span><span class="typ">Encapsulate</span><span class="pun">(</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="59"></td><td class="FileContents-lineContents" id="59"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> </span><span class="typ">KeyAgreementResponse</span><span class="pun">&</span><span class="pln"> peers_key</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="60"></td><td class="FileContents-lineContents" id="60"><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pun">*</span><span class="pln"> out_shared_key</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">const</span><span class="pln"> override </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="61"></td><td class="FileContents-lineContents" id="61"><span class="pln"> bssl</span><span class="pun">::</span><span class="typ">UniquePtr</span><span class="pun"><</span><span class="pln">EC_KEY</span><span class="pun">></span><span class="pln"> key</span><span class="pun">(</span><span class="pln">EC_KEY_new_by_curve_name</span><span class="pun">(</span><span class="pln">NID_X9_62_prime256v1</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="62"></td><td class="FileContents-lineContents" id="62"><span class="pln"> CHECK</span><span class="pun">(</span><span class="pln">EC_KEY_generate_key</span><span class="pun">(</span><span class="pln">key</span><span class="pun">.</span><span class="pln">get</span><span class="pun">()));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="63"></td><td class="FileContents-lineContents" id="63"><span class="pln"> std</span><span class="pun">::</span><span class="pln">optional</span><span class="pun"><</span><span class="pln">bssl</span><span class="pun">::</span><span class="typ">UniquePtr</span><span class="pun"><</span><span class="pln">EC_POINT</span><span class="pun">>></span><span class="pln"> peers_point </span><span class="pun">=</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="64"></td><td class="FileContents-lineContents" id="64"><span class="pln"> </span><span class="typ">PointFromKeyAgreementResponse</span><span class="pun">(</span><span class="pln">EC_KEY_get0_group</span><span class="pun">(</span><span class="pln">key</span><span class="pun">.</span><span class="pln">get</span><span class="pun">()),</span><span class="pln"> peers_key</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="65"></td><td class="FileContents-lineContents" id="65"><span class="pln"> </span><span class="pun">*</span><span class="pln">out_shared_key </span><span class="pun">=</span><span class="pln"> </span><span class="typ">CalculateSharedKey</span><span class="pun">(</span><span class="pln">key</span><span class="pun">.</span><span class="pln">get</span><span class="pun">(),</span><span class="pln"> peers_point</span><span class="pun">-></span><span class="pln">get</span><span class="pun">());</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="66"></td><td class="FileContents-lineContents" id="66"><span class="pln"> </span><span class="com">// KeyAgreementResponse parsing ensures that the point is on the curve.</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="67"></td><td class="FileContents-lineContents" id="67"><span class="pln"> DCHECK</span><span class="pun">(</span><span class="pln">peers_point</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="68"></td><td class="FileContents-lineContents" id="68"><span class="pln"> std</span><span class="pun">::</span><span class="pln">array</span><span class="pun"><</span><span class="typ">uint8_t</span><span class="pun">,</span><span class="pln"> kP256X962Length</span><span class="pun">></span><span class="pln"> x962</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="69"></td><td class="FileContents-lineContents" id="69"><span class="pln"> CHECK_EQ</span><span class="pun">(</span><span class="pln">x962</span><span class="pun">.</span><span class="pln">size</span><span class="pun">(),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="70"></td><td class="FileContents-lineContents" id="70"><span class="pln"> EC_POINT_point2oct</span><span class="pun">(</span><span class="pln">EC_KEY_get0_group</span><span class="pun">(</span><span class="pln">key</span><span class="pun">.</span><span class="pln">get</span><span class="pun">()),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="71"></td><td class="FileContents-lineContents" id="71"><span class="pln"> EC_KEY_get0_public_key</span><span class="pun">(</span><span class="pln">key</span><span class="pun">.</span><span class="pln">get</span><span class="pun">()),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="72"></td><td class="FileContents-lineContents" id="72"><span class="pln"> POINT_CONVERSION_UNCOMPRESSED</span><span class="pun">,</span><span class="pln"> x962</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="73"></td><td class="FileContents-lineContents" id="73"><span class="pln"> x962</span><span class="pun">.</span><span class="pln">size</span><span class="pun">(),</span><span class="pln"> </span><span class="kwd">nullptr</span><span class="pln"> </span><span class="com">/* BN_CTX */</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="74"></td><td class="FileContents-lineContents" id="74"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="75"></td><td class="FileContents-lineContents" id="75"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> x962</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="76"></td><td class="FileContents-lineContents" id="76"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="77"></td><td class="FileContents-lineContents" id="77"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="78"></td><td class="FileContents-lineContents" id="78"><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> </span><span class="typ">Encrypt</span><span class="pun">(</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="79"></td><td class="FileContents-lineContents" id="79"><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> shared_key</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="80"></td><td class="FileContents-lineContents" id="80"><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> plaintext</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">const</span><span class="pln"> override </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="81"></td><td class="FileContents-lineContents" id="81"><span class="pln"> DCHECK_EQ</span><span class="pun">(</span><span class="pln">plaintext</span><span class="pun">.</span><span class="pln">size</span><span class="pun">()</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> AES_BLOCK_SIZE</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0u</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="82"></td><td class="FileContents-lineContents" id="82"><span class="pln"> DCHECK_EQ</span><span class="pun">(</span><span class="pln">shared_key</span><span class="pun">.</span><span class="pln">size</span><span class="pun">(),</span><span class="pln"> kSharedKeySize</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="83"></td><td class="FileContents-lineContents" id="83"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="84"></td><td class="FileContents-lineContents" id="84"><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> ciphertext</span><span class="pun">(</span><span class="pln">plaintext</span><span class="pun">.</span><span class="pln">size</span><span class="pun">());</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="85"></td><td class="FileContents-lineContents" id="85"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="86"></td><td class="FileContents-lineContents" id="86"><span class="pln"> EVP_CIPHER_CTX aes_ctx</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="87"></td><td class="FileContents-lineContents" id="87"><span class="pln"> EVP_CIPHER_CTX_init</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="88"></td><td class="FileContents-lineContents" id="88"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pln"> kZeroIV</span><span class="pun">[</span><span class="pln">AES_BLOCK_SIZE</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pun">{};</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="89"></td><td class="FileContents-lineContents" id="89"><span class="pln"> CHECK</span><span class="pun">(</span><span class="pln">EVP_EncryptInit_ex</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">,</span><span class="pln"> EVP_aes_256_cbc</span><span class="pun">(),</span><span class="pln"> </span><span class="kwd">nullptr</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="90"></td><td class="FileContents-lineContents" id="90"><span class="pln"> shared_key</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> kZeroIV</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="91"></td><td class="FileContents-lineContents" id="91"><span class="pln"> CHECK</span><span class="pun">(</span><span class="pln">EVP_CIPHER_CTX_set_padding</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="com">/* no padding */</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="92"></td><td class="FileContents-lineContents" id="92"><span class="pln"> CHECK</span><span class="pun">(</span><span class="pln">EVP_Cipher</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">,</span><span class="pln"> ciphertext</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> plaintext</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="93"></td><td class="FileContents-lineContents" id="93"><span class="pln"> plaintext</span><span class="pun">.</span><span class="pln">size</span><span class="pun">()));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="94"></td><td class="FileContents-lineContents" id="94"><span class="pln"> EVP_CIPHER_CTX_cleanup</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="95"></td><td class="FileContents-lineContents" id="95"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> ciphertext</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="96"></td><td class="FileContents-lineContents" id="96"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="97"></td><td class="FileContents-lineContents" id="97"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="98"></td><td class="FileContents-lineContents" id="98"><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> </span><span class="typ">Decrypt</span><span class="pun">(</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="99"></td><td class="FileContents-lineContents" id="99"><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> shared_key</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="100"></td><td class="FileContents-lineContents" id="100"><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> ciphertext</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">const</span><span class="pln"> override </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="101"></td><td class="FileContents-lineContents" id="101"><span class="pln"> DCHECK_EQ</span><span class="pun">(</span><span class="pln">ciphertext</span><span class="pun">.</span><span class="pln">size</span><span class="pun">()</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> AES_BLOCK_SIZE</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0u</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="102"></td><td class="FileContents-lineContents" id="102"><span class="pln"> DCHECK_EQ</span><span class="pun">(</span><span class="pln">shared_key</span><span class="pun">.</span><span class="pln">size</span><span class="pun">(),</span><span class="pln"> kSharedKeySize</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="103"></td><td class="FileContents-lineContents" id="103"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="104"></td><td class="FileContents-lineContents" id="104"><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> plaintext</span><span class="pun">(</span><span class="pln">ciphertext</span><span class="pun">.</span><span class="pln">size</span><span class="pun">());</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="105"></td><td class="FileContents-lineContents" id="105"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="106"></td><td class="FileContents-lineContents" id="106"><span class="pln"> EVP_CIPHER_CTX aes_ctx</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="107"></td><td class="FileContents-lineContents" id="107"><span class="pln"> EVP_CIPHER_CTX_init</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="108"></td><td class="FileContents-lineContents" id="108"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pln"> kZeroIV</span><span class="pun">[</span><span class="pln">AES_BLOCK_SIZE</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pun">{};</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="109"></td><td class="FileContents-lineContents" id="109"><span class="pln"> CHECK</span><span class="pun">(</span><span class="pln">EVP_DecryptInit_ex</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">,</span><span class="pln"> EVP_aes_256_cbc</span><span class="pun">(),</span><span class="pln"> </span><span class="kwd">nullptr</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="110"></td><td class="FileContents-lineContents" id="110"><span class="pln"> shared_key</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> kZeroIV</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="111"></td><td class="FileContents-lineContents" id="111"><span class="pln"> CHECK</span><span class="pun">(</span><span class="pln">EVP_CIPHER_CTX_set_padding</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="com">/* no padding */</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="112"></td><td class="FileContents-lineContents" id="112"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="113"></td><td class="FileContents-lineContents" id="113"><span class="pln"> CHECK</span><span class="pun">(</span><span class="pln">EVP_Cipher</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">,</span><span class="pln"> plaintext</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> ciphertext</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="114"></td><td class="FileContents-lineContents" id="114"><span class="pln"> ciphertext</span><span class="pun">.</span><span class="pln">size</span><span class="pun">()));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="115"></td><td class="FileContents-lineContents" id="115"><span class="pln"> EVP_CIPHER_CTX_cleanup</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="116"></td><td class="FileContents-lineContents" id="116"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> plaintext</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="117"></td><td class="FileContents-lineContents" id="117"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="118"></td><td class="FileContents-lineContents" id="118"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="119"></td><td class="FileContents-lineContents" id="119"><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> </span><span class="typ">Authenticate</span><span class="pun">(</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="120"></td><td class="FileContents-lineContents" id="120"><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> key</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="121"></td><td class="FileContents-lineContents" id="121"><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> data</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">const</span><span class="pln"> override </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="122"></td><td class="FileContents-lineContents" id="122"><span class="pln"> </span><span class="com">// Authenticate can be invoked with the shared secret or with a PIN/UV Auth</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="123"></td><td class="FileContents-lineContents" id="123"><span class="pln"> </span><span class="com">// Token. In CTAP2.1, V1 tokens are fixed at 16 or 32 bytes. But in CTAP2.0</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="124"></td><td class="FileContents-lineContents" id="124"><span class="pln"> </span><span class="com">// they may be any multiple of 16 bytes. We don't know the CTAP version, so</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="125"></td><td class="FileContents-lineContents" id="125"><span class="pln"> </span><span class="com">// only enforce the latter.</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="126"></td><td class="FileContents-lineContents" id="126"><span class="pln"> </span><span class="kwd">static_assert</span><span class="pun">(</span><span class="pln">kSharedKeySize </span><span class="pun">==</span><span class="pln"> </span><span class="lit">32u</span><span class="pun">,</span><span class="pln"> </span><span class="str">""</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="127"></td><td class="FileContents-lineContents" id="127"><span class="pln"> DCHECK_EQ</span><span class="pun">(</span><span class="pln">key</span><span class="pun">.</span><span class="pln">size</span><span class="pun">()</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> AES_BLOCK_SIZE</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0u</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="128"></td><td class="FileContents-lineContents" id="128"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="129"></td><td class="FileContents-lineContents" id="129"><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> pin_auth</span><span class="pun">(</span><span class="pln">SHA256_DIGEST_LENGTH</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="130"></td><td class="FileContents-lineContents" id="130"><span class="pln"> </span><span class="kwd">unsigned</span><span class="pln"> hmac_bytes</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="131"></td><td class="FileContents-lineContents" id="131"><span class="pln"> CHECK</span><span class="pun">(</span><span class="pln">HMAC</span><span class="pun">(</span><span class="pln">EVP_sha256</span><span class="pun">(),</span><span class="pln"> key</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> key</span><span class="pun">.</span><span class="pln">size</span><span class="pun">(),</span><span class="pln"> data</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> data</span><span class="pun">.</span><span class="pln">size</span><span class="pun">(),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="132"></td><td class="FileContents-lineContents" id="132"><span class="pln"> pin_auth</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> </span><span class="pun">&</span><span class="pln">hmac_bytes</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="133"></td><td class="FileContents-lineContents" id="133"><span class="pln"> DCHECK_EQ</span><span class="pun">(</span><span class="pln">pin_auth</span><span class="pun">.</span><span class="pln">size</span><span class="pun">(),</span><span class="pln"> </span><span class="kwd">static_cast</span><span class="str"><size_t></span><span class="pun">(</span><span class="pln">hmac_bytes</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="134"></td><td class="FileContents-lineContents" id="134"><span class="pln"> pin_auth</span><span class="pun">.</span><span class="pln">resize</span><span class="pun">(</span><span class="pln">kSignatureSize</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="135"></td><td class="FileContents-lineContents" id="135"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> pin_auth</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="136"></td><td class="FileContents-lineContents" id="136"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="137"></td><td class="FileContents-lineContents" id="137"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="138"></td><td class="FileContents-lineContents" id="138"><span class="pln"> </span><span class="kwd">bool</span><span class="pln"> </span><span class="typ">Verify</span><span class="pun">(</span><span class="pln">base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> key</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="139"></td><td class="FileContents-lineContents" id="139"><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> data</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="140"></td><td class="FileContents-lineContents" id="140"><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> signature</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">const</span><span class="pln"> override </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="141"></td><td class="FileContents-lineContents" id="141"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">signature</span><span class="pun">.</span><span class="pln">size</span><span class="pun">()</span><span class="pln"> </span><span class="pun">!=</span><span class="pln"> kSignatureSize</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="142"></td><td class="FileContents-lineContents" id="142"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="143"></td><td class="FileContents-lineContents" id="143"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="144"></td><td class="FileContents-lineContents" id="144"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> computed_signature </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Authenticate</span><span class="pun">(</span><span class="pln">key</span><span class="pun">,</span><span class="pln"> data</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="145"></td><td class="FileContents-lineContents" id="145"><span class="pln"> CHECK_EQ</span><span class="pun">(</span><span class="pln">computed_signature</span><span class="pun">.</span><span class="pln">size</span><span class="pun">(),</span><span class="pln"> kSignatureSize</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="146"></td><td class="FileContents-lineContents" id="146"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> CRYPTO_memcmp</span><span class="pun">(</span><span class="pln">signature</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> computed_signature</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="147"></td><td class="FileContents-lineContents" id="147"><span class="pln"> kSignatureSize</span><span class="pun">)</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="148"></td><td class="FileContents-lineContents" id="148"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="149"></td><td class="FileContents-lineContents" id="149"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="150"></td><td class="FileContents-lineContents" id="150"><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> </span><span class="typ">CalculateSharedKey</span><span class="pun">(</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="151"></td><td class="FileContents-lineContents" id="151"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> EC_KEY</span><span class="pun">*</span><span class="pln"> key</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="152"></td><td class="FileContents-lineContents" id="152"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> EC_POINT</span><span class="pun">*</span><span class="pln"> peers_key</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">const</span><span class="pln"> override </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="153"></td><td class="FileContents-lineContents" id="153"><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> shared_key</span><span class="pun">(</span><span class="pln">SHA256_DIGEST_LENGTH</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="154"></td><td class="FileContents-lineContents" id="154"><span class="pln"> CHECK_EQ</span><span class="pun">(</span><span class="kwd">static_cast</span><span class="str"><int></span><span class="pun">(</span><span class="pln">SHA256_DIGEST_LENGTH</span><span class="pun">),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="155"></td><td class="FileContents-lineContents" id="155"><span class="pln"> ECDH_compute_key</span><span class="pun">(</span><span class="pln">shared_key</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> shared_key</span><span class="pun">.</span><span class="pln">size</span><span class="pun">(),</span><span class="pln"> peers_key</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="156"></td><td class="FileContents-lineContents" id="156"><span class="pln"> key</span><span class="pun">,</span><span class="pln"> SHA256KDF</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="157"></td><td class="FileContents-lineContents" id="157"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> shared_key</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="158"></td><td class="FileContents-lineContents" id="158"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="159"></td><td class="FileContents-lineContents" id="159"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="160"></td><td class="FileContents-lineContents" id="160"><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">void</span><span class="pun">*</span><span class="pln"> SHA256KDF</span><span class="pun">(</span><span class="kwd">const</span><span class="pln"> </span><span class="kwd">void</span><span class="pun">*</span><span class="pln"> in</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="161"></td><td class="FileContents-lineContents" id="161"><span class="pln"> </span><span class="typ">size_t</span><span class="pln"> in_len</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="162"></td><td class="FileContents-lineContents" id="162"><span class="pln"> </span><span class="kwd">void</span><span class="pun">*</span><span class="pln"> out</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="163"></td><td class="FileContents-lineContents" id="163"><span class="pln"> </span><span class="typ">size_t</span><span class="pun">*</span><span class="pln"> out_len</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="164"></td><td class="FileContents-lineContents" id="164"><span class="pln"> DCHECK_GE</span><span class="pun">(*</span><span class="pln">out_len</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">static_cast</span><span class="str"><size_t></span><span class="pun">(</span><span class="pln">SHA256_DIGEST_LENGTH</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="165"></td><td class="FileContents-lineContents" id="165"><span class="pln"> SHA256</span><span class="pun">(</span><span class="kwd">reinterpret_cast</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">*>(</span><span class="pln">in</span><span class="pun">),</span><span class="pln"> in_len</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="166"></td><td class="FileContents-lineContents" id="166"><span class="pln"> </span><span class="kwd">reinterpret_cast</span><span class="pun"><</span><span class="typ">uint8_t</span><span class="pun">*>(</span><span class="pln">out</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="167"></td><td class="FileContents-lineContents" id="167"><span class="pln"> </span><span class="pun">*</span><span class="pln">out_len </span><span class="pun">=</span><span class="pln"> SHA256_DIGEST_LENGTH</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="168"></td><td class="FileContents-lineContents" id="168"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> out</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="169"></td><td class="FileContents-lineContents" id="169"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="170"></td><td class="FileContents-lineContents" id="170"><span class="pun">};</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="171"></td><td class="FileContents-lineContents" id="171"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="172"></td><td class="FileContents-lineContents" id="172"><span class="com">// ProtocolV2 implements CTAP2.1 PIN/UV Auth Protocol Two (6.5.11).</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="173"></td><td class="FileContents-lineContents" id="173"><span class="kwd">class</span><span class="pln"> </span><span class="typ">ProtocolV2</span><span class="pln"> </span><span class="pun">:</span><span class="pln"> </span><span class="kwd">public</span><span class="pln"> </span><span class="typ">ProtocolV1</span><span class="pln"> </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="174"></td><td class="FileContents-lineContents" id="174"><span class="pln"> </span><span class="kwd">private</span><span class="pun">:</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="175"></td><td class="FileContents-lineContents" id="175"><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">constexpr</span><span class="pln"> </span><span class="typ">size_t</span><span class="pln"> kAESKeyLength </span><span class="pun">=</span><span class="pln"> </span><span class="lit">32</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="176"></td><td class="FileContents-lineContents" id="176"><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">constexpr</span><span class="pln"> </span><span class="typ">size_t</span><span class="pln"> kHMACKeyLength </span><span class="pun">=</span><span class="pln"> </span><span class="lit">32</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="177"></td><td class="FileContents-lineContents" id="177"><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">constexpr</span><span class="pln"> </span><span class="typ">size_t</span><span class="pln"> kSharedKeyLength </span><span class="pun">=</span><span class="pln"> kAESKeyLength </span><span class="pun">+</span><span class="pln"> kHMACKeyLength</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="178"></td><td class="FileContents-lineContents" id="178"><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">constexpr</span><span class="pln"> </span><span class="typ">size_t</span><span class="pln"> kPINUVAuthTokenLength </span><span class="pun">=</span><span class="pln"> </span><span class="lit">32</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="179"></td><td class="FileContents-lineContents" id="179"><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">constexpr</span><span class="pln"> </span><span class="typ">size_t</span><span class="pln"> kSignatureSize </span><span class="pun">=</span><span class="pln"> SHA256_DIGEST_LENGTH</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="180"></td><td class="FileContents-lineContents" id="180"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="181"></td><td class="FileContents-lineContents" id="181"><span class="pln"> </span><span class="com">// GetHMACSubKey returns the HMAC-key portion of the shared secret.</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="182"></td><td class="FileContents-lineContents" id="182"><span class="pln"> </span><span class="kwd">static</span><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">,</span><span class="pln"> kHMACKeyLength</span><span class="pun">></span><span class="pln"> </span><span class="typ">GetHMACSubKey</span><span class="pun">(</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="183"></td><td class="FileContents-lineContents" id="183"><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">,</span><span class="pln"> kSharedKeyLength</span><span class="pun">></span><span class="pln"> shared_key</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="184"></td><td class="FileContents-lineContents" id="184"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> shared_key</span><span class="pun">.</span><span class="pln">first</span><span class="str"><kHMACKeyLength></span><span class="pun">();</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="185"></td><td class="FileContents-lineContents" id="185"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="186"></td><td class="FileContents-lineContents" id="186"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="187"></td><td class="FileContents-lineContents" id="187"><span class="pln"> </span><span class="com">// GetAESSubKey returns the HMAC-key portion of the shared secret.</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="188"></td><td class="FileContents-lineContents" id="188"><span class="pln"> </span><span class="kwd">static</span><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">,</span><span class="pln"> kAESKeyLength</span><span class="pun">></span><span class="pln"> </span><span class="typ">GetAESSubKey</span><span class="pun">(</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="189"></td><td class="FileContents-lineContents" id="189"><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">,</span><span class="pln"> kSharedKeyLength</span><span class="pun">></span><span class="pln"> shared_key</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="190"></td><td class="FileContents-lineContents" id="190"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> shared_key</span><span class="pun">.</span><span class="pln">last</span><span class="str"><kAESKeyLength></span><span class="pun">();</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="191"></td><td class="FileContents-lineContents" id="191"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="192"></td><td class="FileContents-lineContents" id="192"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="193"></td><td class="FileContents-lineContents" id="193"><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> </span><span class="typ">Encrypt</span><span class="pun">(</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="194"></td><td class="FileContents-lineContents" id="194"><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> shared_key</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="195"></td><td class="FileContents-lineContents" id="195"><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> plaintext</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">const</span><span class="pln"> override </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="196"></td><td class="FileContents-lineContents" id="196"><span class="pln"> DCHECK_EQ</span><span class="pun">(</span><span class="pln">plaintext</span><span class="pun">.</span><span class="pln">size</span><span class="pun">()</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> AES_BLOCK_SIZE</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0u</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="197"></td><td class="FileContents-lineContents" id="197"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="198"></td><td class="FileContents-lineContents" id="198"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">,</span><span class="pln"> kAESKeyLength</span><span class="pun">></span><span class="pln"> aes_key </span><span class="pun">=</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="199"></td><td class="FileContents-lineContents" id="199"><span class="pln"> </span><span class="typ">GetAESSubKey</span><span class="pun">(*</span><span class="pln">shared_key</span><span class="pun">.</span><span class="pln">to_fixed_extent</span><span class="str"><kSharedKeyLength></span><span class="pun">());</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="200"></td><td class="FileContents-lineContents" id="200"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="201"></td><td class="FileContents-lineContents" id="201"><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> result</span><span class="pun">(</span><span class="pln">AES_BLOCK_SIZE </span><span class="pun">+</span><span class="pln"> plaintext</span><span class="pun">.</span><span class="pln">size</span><span class="pun">());</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="202"></td><td class="FileContents-lineContents" id="202"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="str"><uint8_t></span><span class="pln"> iv </span><span class="pun">=</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="203"></td><td class="FileContents-lineContents" id="203"><span class="pln"> base</span><span class="pun">::</span><span class="pln">make_span</span><span class="pun">(</span><span class="pln">result</span><span class="pun">).</span><span class="pln">first</span><span class="pun"><</span><span class="pln">AES_BLOCK_SIZE</span><span class="pun">>();</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="204"></td><td class="FileContents-lineContents" id="204"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="str"><uint8_t></span><span class="pln"> ciphertext </span><span class="pun">=</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="205"></td><td class="FileContents-lineContents" id="205"><span class="pln"> base</span><span class="pun">::</span><span class="pln">make_span</span><span class="pun">(</span><span class="pln">result</span><span class="pun">).</span><span class="pln">subspan</span><span class="pun"><</span><span class="pln">AES_BLOCK_SIZE</span><span class="pun">>();</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="206"></td><td class="FileContents-lineContents" id="206"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="207"></td><td class="FileContents-lineContents" id="207"><span class="pln"> crypto</span><span class="pun">::</span><span class="typ">RandBytes</span><span class="pun">(</span><span class="pln">iv</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="208"></td><td class="FileContents-lineContents" id="208"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="209"></td><td class="FileContents-lineContents" id="209"><span class="pln"> EVP_CIPHER_CTX aes_ctx</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="210"></td><td class="FileContents-lineContents" id="210"><span class="pln"> EVP_CIPHER_CTX_init</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="211"></td><td class="FileContents-lineContents" id="211"><span class="pln"> CHECK</span><span class="pun">(</span><span class="pln">EVP_EncryptInit_ex</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">,</span><span class="pln"> EVP_aes_256_cbc</span><span class="pun">(),</span><span class="pln"> </span><span class="kwd">nullptr</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="212"></td><td class="FileContents-lineContents" id="212"><span class="pln"> aes_key</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> iv</span><span class="pun">.</span><span class="pln">data</span><span class="pun">()));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="213"></td><td class="FileContents-lineContents" id="213"><span class="pln"> CHECK</span><span class="pun">(</span><span class="pln">EVP_CIPHER_CTX_set_padding</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="com">/* no padding */</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="214"></td><td class="FileContents-lineContents" id="214"><span class="pln"> CHECK</span><span class="pun">(</span><span class="pln">EVP_Cipher</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">,</span><span class="pln"> ciphertext</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> plaintext</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="215"></td><td class="FileContents-lineContents" id="215"><span class="pln"> plaintext</span><span class="pun">.</span><span class="pln">size</span><span class="pun">()));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="216"></td><td class="FileContents-lineContents" id="216"><span class="pln"> EVP_CIPHER_CTX_cleanup</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="217"></td><td class="FileContents-lineContents" id="217"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="218"></td><td class="FileContents-lineContents" id="218"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> result</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="219"></td><td class="FileContents-lineContents" id="219"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="220"></td><td class="FileContents-lineContents" id="220"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="221"></td><td class="FileContents-lineContents" id="221"><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> </span><span class="typ">Decrypt</span><span class="pun">(</span><span class="pln">base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> shared_key</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="222"></td><td class="FileContents-lineContents" id="222"><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> input</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">const</span><span class="pln"> override </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="223"></td><td class="FileContents-lineContents" id="223"><span class="pln"> DCHECK_EQ</span><span class="pun">(</span><span class="pln">input</span><span class="pun">.</span><span class="pln">size</span><span class="pun">()</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> AES_BLOCK_SIZE</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0u</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="224"></td><td class="FileContents-lineContents" id="224"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="225"></td><td class="FileContents-lineContents" id="225"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">,</span><span class="pln"> kAESKeyLength</span><span class="pun">></span><span class="pln"> aes_key </span><span class="pun">=</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="226"></td><td class="FileContents-lineContents" id="226"><span class="pln"> </span><span class="typ">GetAESSubKey</span><span class="pun">(*</span><span class="pln">shared_key</span><span class="pun">.</span><span class="pln">to_fixed_extent</span><span class="str"><kSharedKeyLength></span><span class="pun">());</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="227"></td><td class="FileContents-lineContents" id="227"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> iv </span><span class="pun">=</span><span class="pln"> input</span><span class="pun">.</span><span class="pln">first</span><span class="pun"><</span><span class="pln">AES_BLOCK_SIZE</span><span class="pun">>();</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="228"></td><td class="FileContents-lineContents" id="228"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> ciphertext </span><span class="pun">=</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="229"></td><td class="FileContents-lineContents" id="229"><span class="pln"> input</span><span class="pun">.</span><span class="pln">subspan</span><span class="pun"><</span><span class="pln">AES_BLOCK_SIZE</span><span class="pun">>();</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="230"></td><td class="FileContents-lineContents" id="230"><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> plaintext</span><span class="pun">(</span><span class="pln">ciphertext</span><span class="pun">.</span><span class="pln">size</span><span class="pun">());</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="231"></td><td class="FileContents-lineContents" id="231"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="232"></td><td class="FileContents-lineContents" id="232"><span class="pln"> EVP_CIPHER_CTX aes_ctx</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="233"></td><td class="FileContents-lineContents" id="233"><span class="pln"> EVP_CIPHER_CTX_init</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="234"></td><td class="FileContents-lineContents" id="234"><span class="pln"> CHECK</span><span class="pun">(</span><span class="pln">EVP_DecryptInit_ex</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">,</span><span class="pln"> EVP_aes_256_cbc</span><span class="pun">(),</span><span class="pln"> </span><span class="kwd">nullptr</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="235"></td><td class="FileContents-lineContents" id="235"><span class="pln"> aes_key</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> iv</span><span class="pun">.</span><span class="pln">data</span><span class="pun">()));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="236"></td><td class="FileContents-lineContents" id="236"><span class="pln"> CHECK</span><span class="pun">(</span><span class="pln">EVP_CIPHER_CTX_set_padding</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="com">/* no padding */</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="237"></td><td class="FileContents-lineContents" id="237"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="238"></td><td class="FileContents-lineContents" id="238"><span class="pln"> CHECK</span><span class="pun">(</span><span class="pln">EVP_Cipher</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">,</span><span class="pln"> plaintext</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> ciphertext</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="239"></td><td class="FileContents-lineContents" id="239"><span class="pln"> ciphertext</span><span class="pun">.</span><span class="pln">size</span><span class="pun">()));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="240"></td><td class="FileContents-lineContents" id="240"><span class="pln"> EVP_CIPHER_CTX_cleanup</span><span class="pun">(&</span><span class="pln">aes_ctx</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="241"></td><td class="FileContents-lineContents" id="241"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="242"></td><td class="FileContents-lineContents" id="242"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> plaintext</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="243"></td><td class="FileContents-lineContents" id="243"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="244"></td><td class="FileContents-lineContents" id="244"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="245"></td><td class="FileContents-lineContents" id="245"><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> </span><span class="typ">Authenticate</span><span class="pun">(</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="246"></td><td class="FileContents-lineContents" id="246"><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> key</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="247"></td><td class="FileContents-lineContents" id="247"><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> data</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">const</span><span class="pln"> override </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="248"></td><td class="FileContents-lineContents" id="248"><span class="pln"> </span><span class="com">// Authenticate can be invoked with the shared secret or with a PIN/UV Auth</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="249"></td><td class="FileContents-lineContents" id="249"><span class="pln"> </span><span class="com">// Token, which is fixed at 32 bytes in V2.</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="250"></td><td class="FileContents-lineContents" id="250"><span class="pln"> DCHECK</span><span class="pun">(</span><span class="pln">key</span><span class="pun">.</span><span class="pln">size</span><span class="pun">()</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> kSharedKeyLength </span><span class="pun">||</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="251"></td><td class="FileContents-lineContents" id="251"><span class="pln"> key</span><span class="pun">.</span><span class="pln">size</span><span class="pun">()</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> kPINUVAuthTokenLength</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="252"></td><td class="FileContents-lineContents" id="252"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">,</span><span class="pln"> kHMACKeyLength</span><span class="pun">></span><span class="pln"> hmac_key </span><span class="pun">=</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="253"></td><td class="FileContents-lineContents" id="253"><span class="pln"> </span><span class="pun">(</span><span class="pln">key</span><span class="pun">.</span><span class="pln">size</span><span class="pun">()</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> kSharedKeyLength</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="254"></td><td class="FileContents-lineContents" id="254"><span class="pln"> </span><span class="pun">?</span><span class="pln"> </span><span class="typ">GetHMACSubKey</span><span class="pun">(*</span><span class="pln">key</span><span class="pun">.</span><span class="pln">to_fixed_extent</span><span class="str"><kSharedKeyLength></span><span class="pun">())</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="255"></td><td class="FileContents-lineContents" id="255"><span class="pln"> </span><span class="pun">:</span><span class="pln"> </span><span class="pun">*</span><span class="pln">key</span><span class="pun">.</span><span class="pln">to_fixed_extent</span><span class="str"><kPINUVAuthTokenLength></span><span class="pun">());</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="256"></td><td class="FileContents-lineContents" id="256"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="257"></td><td class="FileContents-lineContents" id="257"><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> pin_auth</span><span class="pun">(</span><span class="pln">SHA256_DIGEST_LENGTH</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="258"></td><td class="FileContents-lineContents" id="258"><span class="pln"> </span><span class="kwd">unsigned</span><span class="pln"> hmac_bytes</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="259"></td><td class="FileContents-lineContents" id="259"><span class="pln"> CHECK</span><span class="pun">(</span><span class="pln">HMAC</span><span class="pun">(</span><span class="pln">EVP_sha256</span><span class="pun">(),</span><span class="pln"> hmac_key</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> hmac_key</span><span class="pun">.</span><span class="pln">size</span><span class="pun">(),</span><span class="pln"> data</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="260"></td><td class="FileContents-lineContents" id="260"><span class="pln"> data</span><span class="pun">.</span><span class="pln">size</span><span class="pun">(),</span><span class="pln"> pin_auth</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> </span><span class="pun">&</span><span class="pln">hmac_bytes</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="261"></td><td class="FileContents-lineContents" id="261"><span class="pln"> DCHECK_EQ</span><span class="pun">(</span><span class="pln">pin_auth</span><span class="pun">.</span><span class="pln">size</span><span class="pun">(),</span><span class="pln"> </span><span class="kwd">static_cast</span><span class="str"><size_t></span><span class="pun">(</span><span class="pln">hmac_bytes</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="262"></td><td class="FileContents-lineContents" id="262"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> pin_auth</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="263"></td><td class="FileContents-lineContents" id="263"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="264"></td><td class="FileContents-lineContents" id="264"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="265"></td><td class="FileContents-lineContents" id="265"><span class="pln"> </span><span class="kwd">bool</span><span class="pln"> </span><span class="typ">Verify</span><span class="pun">(</span><span class="pln">base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> key</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="266"></td><td class="FileContents-lineContents" id="266"><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> data</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="267"></td><td class="FileContents-lineContents" id="267"><span class="pln"> base</span><span class="pun">::</span><span class="pln">span</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">></span><span class="pln"> signature</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">const</span><span class="pln"> override </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="268"></td><td class="FileContents-lineContents" id="268"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">signature</span><span class="pun">.</span><span class="pln">size</span><span class="pun">()</span><span class="pln"> </span><span class="pun">!=</span><span class="pln"> kSignatureSize</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="269"></td><td class="FileContents-lineContents" id="269"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="270"></td><td class="FileContents-lineContents" id="270"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="271"></td><td class="FileContents-lineContents" id="271"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> computed_signature </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Authenticate</span><span class="pun">(</span><span class="pln">key</span><span class="pun">,</span><span class="pln"> data</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="272"></td><td class="FileContents-lineContents" id="272"><span class="pln"> CHECK_EQ</span><span class="pun">(</span><span class="pln">computed_signature</span><span class="pun">.</span><span class="pln">size</span><span class="pun">(),</span><span class="pln"> kSignatureSize</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="273"></td><td class="FileContents-lineContents" id="273"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> CRYPTO_memcmp</span><span class="pun">(</span><span class="pln">signature</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> computed_signature</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="274"></td><td class="FileContents-lineContents" id="274"><span class="pln"> kSignatureSize</span><span class="pun">)</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="275"></td><td class="FileContents-lineContents" id="275"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="276"></td><td class="FileContents-lineContents" id="276"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="277"></td><td class="FileContents-lineContents" id="277"><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> </span><span class="typ">CalculateSharedKey</span><span class="pun">(</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="278"></td><td class="FileContents-lineContents" id="278"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> EC_KEY</span><span class="pun">*</span><span class="pln"> key</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="279"></td><td class="FileContents-lineContents" id="279"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> EC_POINT</span><span class="pun">*</span><span class="pln"> peers_key</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">const</span><span class="pln"> override </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="280"></td><td class="FileContents-lineContents" id="280"><span class="pln"> std</span><span class="pun">::</span><span class="typ">vector</span><span class="str"><uint8_t></span><span class="pln"> shared_key</span><span class="pun">(</span><span class="pln">kSharedKeyLength</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="281"></td><td class="FileContents-lineContents" id="281"><span class="pln"> CHECK_EQ</span><span class="pun">(</span><span class="kwd">static_cast</span><span class="str"><int></span><span class="pun">(</span><span class="pln">kSharedKeyLength</span><span class="pun">),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="282"></td><td class="FileContents-lineContents" id="282"><span class="pln"> ECDH_compute_key</span><span class="pun">(</span><span class="pln">shared_key</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> shared_key</span><span class="pun">.</span><span class="pln">size</span><span class="pun">(),</span><span class="pln"> peers_key</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="283"></td><td class="FileContents-lineContents" id="283"><span class="pln"> key</span><span class="pun">,</span><span class="pln"> KDF</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="284"></td><td class="FileContents-lineContents" id="284"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> shared_key</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="285"></td><td class="FileContents-lineContents" id="285"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="286"></td><td class="FileContents-lineContents" id="286"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="287"></td><td class="FileContents-lineContents" id="287"><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">void</span><span class="pun">*</span><span class="pln"> KDF</span><span class="pun">(</span><span class="kwd">const</span><span class="pln"> </span><span class="kwd">void</span><span class="pun">*</span><span class="pln"> in</span><span class="pun">,</span><span class="pln"> </span><span class="typ">size_t</span><span class="pln"> in_len</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">void</span><span class="pun">*</span><span class="pln"> out</span><span class="pun">,</span><span class="pln"> </span><span class="typ">size_t</span><span class="pun">*</span><span class="pln"> out_len</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="288"></td><td class="FileContents-lineContents" id="288"><span class="pln"> </span><span class="kwd">static_assert</span><span class="pun">(</span><span class="pln">kSharedKeyLength </span><span class="pun">==</span><span class="pln"> </span><span class="lit">2</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> SHA256_DIGEST_LENGTH</span><span class="pun">,</span><span class="pln"> </span><span class="str">""</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="289"></td><td class="FileContents-lineContents" id="289"><span class="pln"> DCHECK_GE</span><span class="pun">(*</span><span class="pln">out_len</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">static_cast</span><span class="str"><size_t></span><span class="pun">(</span><span class="pln">kSharedKeyLength</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="290"></td><td class="FileContents-lineContents" id="290"><span class="pln"> </span><span class="kwd">auto</span><span class="pln"> hmac_key_out </span><span class="pun">=</span><span class="pln"> base</span><span class="pun">::</span><span class="pln">make_span</span><span class="pun">(</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="291"></td><td class="FileContents-lineContents" id="291"><span class="pln"> </span><span class="kwd">static_cast</span><span class="pun"><</span><span class="typ">uint8_t</span><span class="pun">*>(</span><span class="pln">out</span><span class="pun">),</span><span class="pln"> </span><span class="kwd">static_cast</span><span class="str"><size_t></span><span class="pun">(</span><span class="pln">SHA256_DIGEST_LENGTH</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="292"></td><td class="FileContents-lineContents" id="292"><span class="pln"> </span><span class="kwd">auto</span><span class="pln"> aes_key_out </span><span class="pun">=</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="293"></td><td class="FileContents-lineContents" id="293"><span class="pln"> base</span><span class="pun">::</span><span class="pln">make_span</span><span class="pun">(</span><span class="kwd">static_cast</span><span class="pun"><</span><span class="typ">uint8_t</span><span class="pun">*>(</span><span class="pln">out</span><span class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> SHA256_DIGEST_LENGTH</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="294"></td><td class="FileContents-lineContents" id="294"><span class="pln"> </span><span class="kwd">static_cast</span><span class="str"><size_t></span><span class="pun">(</span><span class="pln">SHA256_DIGEST_LENGTH</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="295"></td><td class="FileContents-lineContents" id="295"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="296"></td><td class="FileContents-lineContents" id="296"><span class="pln"> </span><span class="kwd">constexpr</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pln"> kHMACKeyInfo</span><span class="pun">[]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="str">"CTAP2 HMAC key"</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="297"></td><td class="FileContents-lineContents" id="297"><span class="pln"> </span><span class="kwd">constexpr</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pln"> kAESKeyInfo</span><span class="pun">[]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="str">"CTAP2 AES key"</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="298"></td><td class="FileContents-lineContents" id="298"><span class="pln"> </span><span class="kwd">constexpr</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pln"> kZeroSalt</span><span class="pun">[</span><span class="lit">32</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pun">{};</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="299"></td><td class="FileContents-lineContents" id="299"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="300"></td><td class="FileContents-lineContents" id="300"><span class="pln"> CHECK</span><span class="pun">(</span><span class="pln">HKDF</span><span class="pun">(</span><span class="pln">hmac_key_out</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> hmac_key_out</span><span class="pun">.</span><span class="pln">size</span><span class="pun">(),</span><span class="pln"> EVP_sha256</span><span class="pun">(),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="301"></td><td class="FileContents-lineContents" id="301"><span class="pln"> </span><span class="kwd">reinterpret_cast</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">*>(</span><span class="pln">in</span><span class="pun">),</span><span class="pln"> in_len</span><span class="pun">,</span><span class="pln"> kZeroSalt</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="302"></td><td class="FileContents-lineContents" id="302"><span class="pln"> </span><span class="kwd">sizeof</span><span class="pun">(</span><span class="pln">kZeroSalt</span><span class="pun">),</span><span class="pln"> kHMACKeyInfo</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">sizeof</span><span class="pun">(</span><span class="pln">kHMACKeyInfo</span><span class="pun">)</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> </span><span class="lit">1</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="303"></td><td class="FileContents-lineContents" id="303"><span class="pln"> CHECK</span><span class="pun">(</span><span class="pln">HKDF</span><span class="pun">(</span><span class="pln">aes_key_out</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(),</span><span class="pln"> aes_key_out</span><span class="pun">.</span><span class="pln">size</span><span class="pun">(),</span><span class="pln"> EVP_sha256</span><span class="pun">(),</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="304"></td><td class="FileContents-lineContents" id="304"><span class="pln"> </span><span class="kwd">reinterpret_cast</span><span class="pun"><</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">uint8_t</span><span class="pun">*>(</span><span class="pln">in</span><span class="pun">),</span><span class="pln"> in_len</span><span class="pun">,</span><span class="pln"> kZeroSalt</span><span class="pun">,</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="305"></td><td class="FileContents-lineContents" id="305"><span class="pln"> </span><span class="kwd">sizeof</span><span class="pun">(</span><span class="pln">kZeroSalt</span><span class="pun">),</span><span class="pln"> kAESKeyInfo</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">sizeof</span><span class="pun">(</span><span class="pln">kAESKeyInfo</span><span class="pun">)</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> </span><span class="lit">1</span><span class="pun">));</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="306"></td><td class="FileContents-lineContents" id="306"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="307"></td><td class="FileContents-lineContents" id="307"><span class="pln"> </span><span class="pun">*</span><span class="pln">out_len </span><span class="pun">=</span><span class="pln"> kSharedKeyLength</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="308"></td><td class="FileContents-lineContents" id="308"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> out</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="309"></td><td class="FileContents-lineContents" id="309"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="310"></td><td class="FileContents-lineContents" id="310"><span class="pun">};</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="311"></td><td class="FileContents-lineContents" id="311"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="312"></td><td class="FileContents-lineContents" id="312"><span class="com">// static</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="313"></td><td class="FileContents-lineContents" id="313"><span class="kwd">const</span><span class="pln"> </span><span class="typ">Protocol</span><span class="pun">&</span><span class="pln"> </span><span class="typ">ProtocolVersion</span><span class="pun">(</span><span class="typ">PINUVAuthProtocol</span><span class="pln"> protocol</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="314"></td><td class="FileContents-lineContents" id="314"><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">const</span><span class="pln"> base</span><span class="pun">::</span><span class="typ">NoDestructor</span><span class="pun"><</span><span class="typ">ProtocolV1</span><span class="pun">></span><span class="pln"> kProtocolV1</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="315"></td><td class="FileContents-lineContents" id="315"><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">const</span><span class="pln"> base</span><span class="pun">::</span><span class="typ">NoDestructor</span><span class="pun"><</span><span class="typ">ProtocolV2</span><span class="pun">></span><span class="pln"> kProtocolV2</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="316"></td><td class="FileContents-lineContents" id="316"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="317"></td><td class="FileContents-lineContents" id="317"><span class="pln"> </span><span class="kwd">switch</span><span class="pln"> </span><span class="pun">(</span><span class="pln">protocol</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="318"></td><td class="FileContents-lineContents" id="318"><span class="pln"> </span><span class="kwd">case</span><span class="pln"> </span><span class="typ">PINUVAuthProtocol</span><span class="pun">::</span><span class="pln">kV1</span><span class="pun">:</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="319"></td><td class="FileContents-lineContents" id="319"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="pun">*</span><span class="pln">kProtocolV1</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="320"></td><td class="FileContents-lineContents" id="320"><span class="pln"> </span><span class="kwd">case</span><span class="pln"> </span><span class="typ">PINUVAuthProtocol</span><span class="pun">::</span><span class="pln">kV2</span><span class="pun">:</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="321"></td><td class="FileContents-lineContents" id="321"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="pun">*</span><span class="pln">kProtocolV2</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="322"></td><td class="FileContents-lineContents" id="322"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="323"></td><td class="FileContents-lineContents" id="323"><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="324"></td><td class="FileContents-lineContents" id="324"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="325"></td><td class="FileContents-lineContents" id="325"><span class="pun">}</span><span class="pln"> </span><span class="com">// namespace pin</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="326"></td><td class="FileContents-lineContents" id="326"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="327"></td><td class="FileContents-lineContents" id="327"><span class="pun">}</span><span class="pln"> </span><span class="com">// namespace device</span></td></tr></table><script nonce="5w345cOzWnUg1VOlVofKrA">for (let lineNumEl of document.querySelectorAll('td.u-lineNum')) {lineNumEl.onclick = () => {window.location.hash = `#${lineNumEl.getAttribute('data-line-number')}`;};}</script></div> <!-- Container --></div> <!-- Site-content --><footer class="Site-footer"><div class="Footer"><span class="Footer-poweredBy">Powered by <a href="https://gerrit.googlesource.com/gitiles/">Gitiles</a>| <a href="https://policies.google.com/privacy">Privacy</a>| <a href="https://policies.google.com/terms">Terms</a></span><span class="Footer-formats"><a class="u-monospace Footer-formatsItem" href="?format=TEXT">txt</a> <a class="u-monospace Footer-formatsItem" href="?format=JSON">json</a></span></div></footer></body></html>