Debian Codegraph @

third_party/rust/authenticator/src/ctap2/commands/make_credentials.rs

raw
1 use super::get_info::{AuthenticatorInfo, AuthenticatorVersion};
2 use super::{
3 Command, CommandError, CtapResponse, PinUvAuthCommand, RequestCtap1, RequestCtap2, Retryable,
4 StatusCode,
5 };
6 use crate::consts::{PARAMETER_SIZE, U2F_REGISTER, U2F_REQUEST_USER_PRESENCE};
7 use crate::crypto::{
8 parse_u2f_der_certificate, COSEAlgorithm, COSEEC2Key, COSEKey, COSEKeyType, Curve,
9 PinUvAuthParam, PinUvAuthToken,
10 };
11 use crate::ctap2::attestation::{
12 AAGuid, AttestationObject, AttestationStatement, AttestationStatementFidoU2F,
13 AttestedCredentialData, AuthenticatorData, AuthenticatorDataFlags, HmacSecretResponse,
14 };
15 use crate::ctap2::client_data::ClientDataHash;
16 use crate::ctap2::server::{
17 AuthenticationExtensionsClientInputs, AuthenticationExtensionsClientOutputs,
18 AuthenticationExtensionsPRFOutputs, AuthenticatorAttachment, CredentialProtectionPolicy,
19 PublicKeyCredentialDescriptor, PublicKeyCredentialParameters, PublicKeyCredentialUserEntity,
20 RelyingParty, RpIdHash, UserVerificationRequirement,
21 };
22 use crate::ctap2::utils::{read_byte, serde_parse_err};
23 use crate::errors::AuthenticatorError;
24 use crate::transport::errors::{ApduErrorStatus, HIDError};
25 use crate::transport::{FidoDevice, VirtualFidoDevice};
26 use crate::u2ftypes::CTAP1RequestAPDU;
27 use serde::{
28 de::{Error as DesError, MapAccess, Unexpected, Visitor},
29 Deserialize, Deserializer, Serialize, Serializer,
30 };
31 use serde_cbor::{self, de::from_slice, ser, Value};
32 use std::fmt;
33 use std::io::{Cursor, Read};
34
35 #[derive(Debug, PartialEq, Eq)]
36 pub struct MakeCredentialsResult {
37 pub att_obj: AttestationObject,
38 pub attachment: AuthenticatorAttachment,
39 pub extensions: AuthenticationExtensionsClientOutputs,
40 }
41
42 impl MakeCredentialsResult {
43 pub fn from_ctap1(input: &[u8], rp_id_hash: &RpIdHash) -> Result<Self, CommandError> {
44 let mut data = Cursor::new(input);
45 let magic_num = read_byte(&mut data).map_err(CommandError::Deserializing)?;
46 if magic_num != 0x05 {
47 error!("error while parsing registration: magic header not 0x05, but {magic_num}");
48 return Err(CommandError::Deserializing(DesError::invalid_value(
49 serde::de::Unexpected::Unsigned(magic_num as u64),
50 &"0x05",
51 )));
52 }
53 let mut public_key = [0u8; 65];
54 data.read_exact(&mut public_key)
55 .map_err(|_| CommandError::Deserializing(serde_parse_err("PublicKey")))?;
56
57 let credential_id_len = read_byte(&mut data).map_err(CommandError::Deserializing)?;
58 let mut credential_id = vec![0u8; credential_id_len as usize];
59 data.read_exact(&mut credential_id)
60 .map_err(|_| CommandError::Deserializing(serde_parse_err("CredentialId")))?;
61
62 let cert_and_sig = parse_u2f_der_certificate(&data.get_ref()[data.position() as usize..])
63 .map_err(|err| {
64 CommandError::Deserializing(serde_parse_err(&format!(
65 "Certificate and Signature: {err:?}",
66 )))
67 })?;
68
69 let credential_ec2_key = COSEEC2Key::from_sec1_uncompressed(Curve::SECP256R1, &public_key)
70 .map_err(|err| {
71 CommandError::Deserializing(serde_parse_err(&format!("EC2 Key: {err:?}",)))
72 })?;
73
74 let credential_public_key = COSEKey {
75 alg: COSEAlgorithm::ES256,
76 key: COSEKeyType::EC2(credential_ec2_key),
77 };
78
79 let auth_data = AuthenticatorData {
80 rp_id_hash: rp_id_hash.clone(),
81 // https://fidoalliance.org/specs/fido-v2.0-ps-20190130/fido-client-to-authenticator-protocol-v2.0-ps-20190130.html#u2f-authenticatorMakeCredential-interoperability
82 // "Let flags be a byte whose zeroth bit (bit 0, UP) is set, and whose sixth bit
83 // (bit 6, AT) is set, and all other bits are zero (bit zero is the least
84 // significant bit)"
85 flags: AuthenticatorDataFlags::USER_PRESENT | AuthenticatorDataFlags::ATTESTED,
86 counter: 0,
87 credential_data: Some(AttestedCredentialData {
88 aaguid: AAGuid::default(),
89 credential_id,
90 credential_public_key,
91 }),
92 extensions: Default::default(),
93 };
94
95 let att_stmt = AttestationStatement::FidoU2F(AttestationStatementFidoU2F::new(
96 cert_and_sig.certificate,
97 cert_and_sig.signature,
98 ));
99
100 let att_obj = AttestationObject {
101 auth_data,
102 att_stmt,
103 };
104
105 Ok(Self {
106 att_obj,
107 attachment: AuthenticatorAttachment::Unknown,
108 extensions: Default::default(),
109 })
110 }
111 }
112
113 impl<'de> Deserialize<'de> for MakeCredentialsResult {
114 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
115 where
116 D: Deserializer<'de>,
117 {
118 struct MakeCredentialsResultVisitor;
119
120 impl<'de> Visitor<'de> for MakeCredentialsResultVisitor {
121 type Value = MakeCredentialsResult;
122
123 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
124 formatter.write_str("a cbor map")
125 }
126
127 fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
128 where
129 M: MapAccess<'de>,
130 {
131 let mut format: Option<&str> = None;
132 let mut auth_data: Option<AuthenticatorData> = None;
133 let mut att_stmt: Option<AttestationStatement> = None;
134
135 while let Some(key) = map.next_key()? {
136 match key {
137 1 => {
138 if format.is_some() {
139 return Err(DesError::duplicate_field("fmt (0x01)"));
140 }
141 format = Some(map.next_value()?);
142 }
143 2 => {
144 if auth_data.is_some() {
145 return Err(DesError::duplicate_field("authData (0x02)"));
146 }
147 auth_data = Some(map.next_value()?);
148 }
149 3 => {
150 let format =
151 format.ok_or_else(|| DesError::missing_field("fmt (0x01)"))?;
152 if att_stmt.is_some() {
153 return Err(DesError::duplicate_field("attStmt (0x03)"));
154 }
155 att_stmt = match format {
156 "none" => {
157 let map: std::collections::BTreeMap<(), ()> =
158 map.next_value()?;
159 if !map.is_empty() {
160 return Err(DesError::invalid_value(
161 Unexpected::Map,
162 &"the empty map",
163 ));
164 }
165 Some(AttestationStatement::None)
166 }
167 "packed" => Some(AttestationStatement::Packed(map.next_value()?)),
168 "fido-u2f" => {
169 Some(AttestationStatement::FidoU2F(map.next_value()?))
170 }
171 _ => {
172 return Err(DesError::custom(
173 "unknown attestation statement format",
174 ))
175 }
176 }
177 }
178 _ => continue,
179 }
180 }
181
182 let auth_data = auth_data
183 .ok_or_else(|| M::Error::custom("found no authData (0x02)".to_string()))?;
184 let att_stmt = att_stmt
185 .ok_or_else(|| M::Error::custom("found no attStmt (0x03)".to_string()))?;
186
187 Ok(MakeCredentialsResult {
188 att_obj: AttestationObject {
189 auth_data,
190 att_stmt,
191 },
192 attachment: AuthenticatorAttachment::Unknown,
193 extensions: Default::default(),
194 })
195 }
196 }
197
198 deserializer.deserialize_bytes(MakeCredentialsResultVisitor)
199 }
200 }
201
202 impl CtapResponse for MakeCredentialsResult {}
203
204 #[derive(Copy, Clone, Debug, Default, Serialize)]
205 #[cfg_attr(test, derive(Deserialize))]
206 pub struct MakeCredentialsOptions {
207 #[serde(rename = "rk", skip_serializing_if = "Option::is_none")]
208 pub resident_key: Option<bool>,
209 #[serde(rename = "uv", skip_serializing_if = "Option::is_none")]
210 pub user_verification: Option<bool>,
211 // TODO(MS): ctap2.1 supports user_presence, but ctap2.0 does not and tokens will error out
212 // Commands need a version-flag to know what to de/serialize and what to ignore.
213 }
214
215 impl MakeCredentialsOptions {
216 pub(crate) fn has_some(&self) -> bool {
217 self.resident_key.is_some() || self.user_verification.is_some()
218 }
219 }
220
221 pub(crate) trait UserVerification {
222 fn ask_user_verification(&self) -> bool;
223 }
224
225 impl UserVerification for MakeCredentialsOptions {
226 fn ask_user_verification(&self) -> bool {
227 if let Some(e) = self.user_verification {
228 e
229 } else {
230 false
231 }
232 }
233 }
234
235 #[derive(Debug, Default, Clone, Serialize)]
236 pub struct MakeCredentialsExtensions {
237 #[serde(skip_serializing)]
238 pub cred_props: Option<bool>,
239 #[serde(rename = "credProtect", skip_serializing_if = "Option::is_none")]
240 pub cred_protect: Option<CredentialProtectionPolicy>,
241 #[serde(rename = "hmac-secret", skip_serializing_if = "Option::is_none")]
242 pub hmac_secret: Option<HmacCreateSecretOrPrf>,
243 #[serde(rename = "minPinLength", skip_serializing_if = "Option::is_none")]
244 pub min_pin_length: Option<bool>,
245 }
246
247 #[derive(Debug, Clone)]
248 pub enum HmacCreateSecretOrPrf {
249 HmacCreateSecret(bool),
250 Prf,
251 }
252
253 impl Serialize for HmacCreateSecretOrPrf {
254 fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
255 where
256 S: Serializer,
257 {
258 match self {
259 Self::HmacCreateSecret(hmac_secret) => s.serialize_bool(*hmac_secret),
260 Self::Prf => s.serialize_bool(true),
261 }
262 }
263 }
264
265 impl MakeCredentialsExtensions {
266 fn has_content(&self) -> bool {
267 self.cred_protect.is_some() || self.hmac_secret.is_some() || self.min_pin_length.is_some()
268 }
269 }
270
271 impl From<AuthenticationExtensionsClientInputs> for MakeCredentialsExtensions {
272 fn from(input: AuthenticationExtensionsClientInputs) -> Self {
273 Self {
274 cred_props: input.cred_props,
275 cred_protect: input.credential_protection_policy,
276 hmac_secret: match (input.hmac_create_secret, input.prf) {
277 (None, None) => None,
278 (_, Some(_)) => Some(HmacCreateSecretOrPrf::Prf),
279 (Some(hmac_secret), _) => {
280 Some(HmacCreateSecretOrPrf::HmacCreateSecret(hmac_secret))
281 }
282 },
283 min_pin_length: input.min_pin_length,
284 }
285 }
286 }
287
288 #[derive(Debug, Clone)]
289 pub struct MakeCredentials {
290 pub client_data_hash: ClientDataHash,
291 pub rp: RelyingParty,
292 // Note(baloo): If none -> ctap1
293 pub user: Option<PublicKeyCredentialUserEntity>,
294 pub pub_cred_params: Vec<PublicKeyCredentialParameters>,
295 pub exclude_list: Vec<PublicKeyCredentialDescriptor>,
296
297 // https://www.w3.org/TR/webauthn/#client-extension-input
298 // The client extension input, which is a value that can be encoded in JSON,
299 // is passed from the WebAuthn Relying Party to the client in the get() or
300 // create() call, while the CBOR authenticator extension input is passed
301 // from the client to the authenticator for authenticator extensions during
302 // the processing of these calls.
303 pub extensions: MakeCredentialsExtensions,
304 pub options: MakeCredentialsOptions,
305 pub pin_uv_auth_param: Option<PinUvAuthParam>,
306 pub enterprise_attestation: Option<u64>,
307 }
308
309 impl MakeCredentials {
310 #[allow(clippy::too_many_arguments)]
311 pub fn new(
312 client_data_hash: ClientDataHash,
313 rp: RelyingParty,
314 user: Option<PublicKeyCredentialUserEntity>,
315 pub_cred_params: Vec<PublicKeyCredentialParameters>,
316 exclude_list: Vec<PublicKeyCredentialDescriptor>,
317 options: MakeCredentialsOptions,
318 extensions: MakeCredentialsExtensions,
319 ) -> Self {
320 Self {
321 client_data_hash,
322 rp,
323 user,
324 pub_cred_params,
325 exclude_list,
326 extensions,
327 options,
328 pin_uv_auth_param: None,
329 enterprise_attestation: None,
330 }
331 }
332
333 pub fn finalize_result<Dev: FidoDevice>(&self, dev: &Dev, result: &mut MakeCredentialsResult) {
334 let maybe_info = dev.get_authenticator_info();
335
336 result.attachment = match maybe_info {
337 Some(info) if info.options.platform_device => AuthenticatorAttachment::Platform,
338 Some(_) => AuthenticatorAttachment::CrossPlatform,
339 None => AuthenticatorAttachment::Unknown,
340 };
341
342 // Handle extensions whose outputs are not encoded in the authenticator data.
343 // 1. credProps
344 // "set clientExtensionResults["credProps"]["rk"] to the value of the
345 // requireResidentKey parameter that was used in the invocation of the
346 // authenticatorMakeCredential operation."
347 // Note: a CTAP 2.0 authenticator is allowed to create a discoverable credential even
348 // if one was not requested, so there is a case in which we cannot confidently
349 // return `rk=false` here. We omit the response entirely in this case.
350 let dev_supports_rk = maybe_info.map_or(false, |info| info.options.resident_key);
351 let requested_rk = self.options.resident_key.unwrap_or(false);
352 let max_supported_version = maybe_info.map_or(AuthenticatorVersion::U2F_V2, |info| {
353 info.max_supported_version()
354 });
355 let rk_uncertain = max_supported_version == AuthenticatorVersion::FIDO_2_0
356 && dev_supports_rk
357 && !requested_rk;
358 if self.extensions.cred_props == Some(true) && !rk_uncertain {
359 result
360 .extensions
361 .cred_props
362 .get_or_insert(Default::default())
363 .rk = requested_rk;
364 }
365
366 // 2. hmac-secret
367 // The extension returns a flag in the authenticator data which we need to mirror as a
368 // client output.
369 // 3. prf
370 // hmac-secret returns a flag in the authenticator data
371 // which we need to mirror as a PRF "enabled" client output.
372 // If a future version of hmac-secret permits calculating secrets in makeCredential,
373 // we also need to decrypt and output them as client outputs.
374 match self.extensions.hmac_secret {
375 Some(HmacCreateSecretOrPrf::HmacCreateSecret(true)) => {
376 result.extensions.hmac_create_secret =
377 Some(match result.att_obj.auth_data.extensions.hmac_secret {
378 Some(HmacSecretResponse::Confirmed(flag)) => flag,
379 Some(HmacSecretResponse::Secret(_)) => true,
380 None => false,
381 });
382 }
383 Some(HmacCreateSecretOrPrf::Prf) => {
384 result.extensions.prf =
385 Some(match &result.att_obj.auth_data.extensions.hmac_secret {
386 None => AuthenticationExtensionsPRFOutputs {
387 enabled: Some(false),
388 results: None,
389 },
390 Some(HmacSecretResponse::Confirmed(flag)) => {
391 AuthenticationExtensionsPRFOutputs {
392 enabled: Some(*flag),
393 results: None,
394 }
395 }
396 Some(hmac_response @ HmacSecretResponse::Secret(_)) => {
397 AuthenticationExtensionsPRFOutputs {
398 enabled: Some(true),
399 results: dev
400 .get_shared_secret()
401 .and_then(|shared_secret| {
402 hmac_response.decrypt_secrets(shared_secret)
403 })
404 .and_then(Result::ok)
405 .map(|outputs| outputs.into()),
406 }
407 }
408 })
409 }
410 None | Some(HmacCreateSecretOrPrf::HmacCreateSecret(false)) => {}
411 }
412 }
413 }
414
415 impl PinUvAuthCommand for MakeCredentials {
416 fn set_pin_uv_auth_param(
417 &mut self,
418 pin_uv_auth_token: Option<PinUvAuthToken>,
419 ) -> Result<(), AuthenticatorError> {
420 let mut param = None;
421 if let Some(token) = pin_uv_auth_token {
422 param = Some(
423 token
424 .derive(self.client_data_hash.as_ref())
425 .map_err(CommandError::Crypto)?,
426 );
427 }
428 self.pin_uv_auth_param = param;
429 Ok(())
430 }
431
432 fn set_uv_option(&mut self, uv: Option<bool>) {
433 self.options.user_verification = uv;
434 }
435
436 fn get_rp_id(&self) -> Option<&String> {
437 Some(&self.rp.id)
438 }
439
440 fn can_skip_user_verification(
441 &mut self,
442 info: &AuthenticatorInfo,
443 uv_req: UserVerificationRequirement,
444 ) -> bool {
445 // TODO(MS): Handle here the case where we NEED a UV, the device supports PINs, but hasn't set a PIN.
446 // For this, the user has to be prompted to set a PIN first (see https://github.com/mozilla/authenticator-rs/issues/223)
447
448 let supports_uv = info.options.user_verification == Some(true);
449 let pin_configured = info.options.client_pin == Some(true);
450
451 // CTAP 2.0 authenticators require user verification if the device is protected
452 let device_protected = supports_uv || pin_configured;
453
454 // CTAP 2.1 authenticators may allow the creation of non-discoverable credentials without
455 // user verification. This is only relevant if the relying party has not requested user
456 // verification.
457 let make_cred_uv_not_required = info.options.make_cred_uv_not_rqd == Some(true)
458 && self.options.resident_key != Some(true)
459 && uv_req == UserVerificationRequirement::Discouraged;
460
461 // Alternatively, CTAP 2.1 authenticators may require user verification regardless of the
462 // RP's requirement.
463 let always_uv = info.options.always_uv == Some(true);
464
465 !always_uv && (!device_protected || make_cred_uv_not_required)
466 }
467
468 fn get_pin_uv_auth_param(&self) -> Option<&PinUvAuthParam> {
469 self.pin_uv_auth_param.as_ref()
470 }
471 }
472
473 impl Serialize for MakeCredentials {
474 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
475 where
476 S: Serializer,
477 {
478 debug!("Serialize MakeCredentials");
479 serialize_map_optional!(
480 serializer,
481 &0x01 => Some(&self.client_data_hash),
482 &0x02 => Some(&self.rp),
483 &0x03 => Some(&self.user),
484 &0x04 => Some(&self.pub_cred_params),
485 &0x05 => (!self.exclude_list.is_empty()).then_some(&self.exclude_list),
486 &0x06 => self.extensions.has_content().then_some(&self.extensions),
487 &0x07 => self.options.has_some().then_some(&self.options),
488 &0x08 => &self.pin_uv_auth_param,
489 &0x09 => self.pin_uv_auth_param.as_ref().map(|p| p.pin_protocol.id()),
490 &0x0a => &self.enterprise_attestation,
491 )
492 }
493 }
494
495 impl RequestCtap1 for MakeCredentials {
496 type Output = MakeCredentialsResult;
497 type AdditionalInfo = ();
498
499 fn ctap1_format(&self) -> Result<(Vec<u8>, ()), HIDError> {
500 let flags = U2F_REQUEST_USER_PRESENCE;
501
502 let mut register_data = Vec::with_capacity(2 * PARAMETER_SIZE);
503 register_data.extend_from_slice(self.client_data_hash.as_ref());
504 register_data.extend_from_slice(self.rp.hash().as_ref());
505 let cmd = U2F_REGISTER;
506 let apdu = CTAP1RequestAPDU::serialize(cmd, flags, &register_data)?;
507
508 Ok((apdu, ()))
509 }
510
511 fn handle_response_ctap1<Dev: FidoDevice>(
512 &self,
513 dev: &mut Dev,
514 status: Result<(), ApduErrorStatus>,
515 input: &[u8],
516 _add_info: &(),
517 ) -> Result<Self::Output, Retryable<HIDError>> {
518 if Err(ApduErrorStatus::ConditionsNotSatisfied) == status {
519 return Err(Retryable::Retry);
520 }
521 if let Err(err) = status {
522 return Err(Retryable::Error(HIDError::ApduStatus(err)));
523 }
524
525 let mut output = MakeCredentialsResult::from_ctap1(input, &self.rp.hash())
526 .map_err(|e| Retryable::Error(HIDError::Command(e)))?;
527 self.finalize_result(dev, &mut output);
528 Ok(output)
529 }
530
531 fn send_to_virtual_device<Dev: VirtualFidoDevice>(
532 &self,
533 dev: &mut Dev,
534 ) -> Result<Self::Output, HIDError> {
535 let mut output = dev.make_credentials(self)?;
536 self.finalize_result(dev, &mut output);
537 Ok(output)
538 }
539 }
540
541 impl RequestCtap2 for MakeCredentials {
542 type Output = MakeCredentialsResult;
543
544 fn command(&self) -> Command {
545 Command::MakeCredentials
546 }
547
548 fn wire_format(&self) -> Result<Vec<u8>, HIDError> {
549 Ok(ser::to_vec(&self).map_err(CommandError::Serializing)?)
550 }
551
552 fn handle_response_ctap2<Dev: FidoDevice>(
553 &self,
554 dev: &mut Dev,
555 input: &[u8],
556 ) -> Result<Self::Output, HIDError> {
557 if input.is_empty() {
558 return Err(HIDError::Command(CommandError::InputTooSmall));
559 }
560
561 let status: StatusCode = input[0].into();
562 debug!("response status code: {:?}", status);
563 if input.len() == 1 {
564 if status.is_ok() {
565 return Err(HIDError::Command(CommandError::InputTooSmall));
566 }
567 return Err(HIDError::Command(CommandError::StatusCode(status, None)));
568 }
569
570 if status.is_ok() {
571 let mut output: MakeCredentialsResult =
572 from_slice(&input[1..]).map_err(CommandError::Deserializing)?;
573 self.finalize_result(dev, &mut output);
574 Ok(output)
575 } else {
576 let data: Value = from_slice(&input[1..]).map_err(CommandError::Deserializing)?;
577 Err(HIDError::Command(CommandError::StatusCode(
578 status,
579 Some(data),
580 )))
581 }
582 }
583
584 fn send_to_virtual_device<Dev: VirtualFidoDevice>(
585 &self,
586 dev: &mut Dev,
587 ) -> Result<Self::Output, HIDError> {
588 let mut output = dev.make_credentials(self)?;
589 self.finalize_result(dev, &mut output);
590 Ok(output)
591 }
592 }
593
594 pub(crate) fn dummy_make_credentials_cmd() -> MakeCredentials {
595 let mut req = MakeCredentials::new(
596 // Hardcoded hash of:
597 // CollectedClientData {
598 // webauthn_type: WebauthnType::Create,
599 // challenge: Challenge::new(vec![0, 1, 2, 3, 4]),
600 // origin: String::new(),
601 // cross_origin: false,
602 // token_binding: None,
603 // }
604 ClientDataHash([
605 208, 206, 230, 252, 125, 191, 89, 154, 145, 157, 184, 251, 149, 19, 17, 38, 159, 14,
606 183, 129, 247, 132, 28, 108, 192, 84, 74, 217, 218, 52, 21, 75,
607 ]),
608 RelyingParty::from("make.me.blink"),
609 Some(PublicKeyCredentialUserEntity {
610 id: vec![0],
611 name: Some(String::from("make.me.blink")),
612 ..Default::default()
613 }),
614 vec![PublicKeyCredentialParameters {
615 alg: COSEAlgorithm::ES256,
616 }],
617 vec![],
618 MakeCredentialsOptions::default(),
619 MakeCredentialsExtensions::default(),
620 );
621 // Using a zero-length pinAuth will trigger the device to blink.
622 // For CTAP1, this gets ignored anyways and we do a 'normal' register
623 // command, which also just blinks.
624 req.pin_uv_auth_param = Some(PinUvAuthParam::create_empty());
625 req
626 }
627
628 #[cfg(test)]
629 pub mod test {
630 use std::convert::TryFrom;
631
632 use super::{MakeCredentials, MakeCredentialsOptions, MakeCredentialsResult};
633 use crate::crypto::{
634 COSEAlgorithm, COSEEC2Key, COSEKey, COSEKeyType, Curve, PinUvAuthParam, PinUvAuthProtocol,
635 };
636 use crate::ctap2::attestation::test::create_attestation_obj;
637 use crate::ctap2::attestation::{
638 AAGuid, AttestationCertificate, AttestationObject, AttestationStatement,
639 AttestationStatementFidoU2F, AttestedCredentialData, AuthenticatorData,
640 AuthenticatorDataFlags, Signature,
641 };
642 use crate::ctap2::client_data::{Challenge, CollectedClientData, TokenBinding, WebauthnType};
643 use crate::ctap2::commands::make_credentials::{
644 HmacCreateSecretOrPrf, MakeCredentialsExtensions,
645 };
646 use crate::ctap2::commands::{RequestCtap1, RequestCtap2};
647 use crate::ctap2::server::{
648 AuthenticatorAttachment, PublicKeyCredentialParameters, PublicKeyCredentialUserEntity,
649 RelyingParty, Transport,
650 };
651 use crate::ctap2::server::{PublicKeyCredentialDescriptor, RpIdHash};
652 use crate::transport::device_selector::Device;
653 use crate::transport::hid::HIDDevice;
654 use crate::transport::{FidoDevice, FidoProtocol};
655 use crate::AuthenticatorInfo;
656 use base64::Engine;
657
658 #[test]
659 fn test_make_credentials_ctap2() {
660 let req = MakeCredentials::new(
661 CollectedClientData {
662 webauthn_type: WebauthnType::Create,
663 challenge: Challenge::from(vec![0x00, 0x01, 0x02, 0x03]),
664 origin: String::from("example.com"),
665 cross_origin: false,
666 token_binding: Some(TokenBinding::Present(String::from("AAECAw"))),
667 }
668 .hash()
669 .expect("failed to serialize client data"),
670 RelyingParty {
671 id: String::from("example.com"),
672 name: Some(String::from("Acme")),
673 },
674 Some(PublicKeyCredentialUserEntity {
675 id: base64::engine::general_purpose::URL_SAFE
676 .decode("MIIBkzCCATigAwIBAjCCAZMwggE4oAMCAQIwggGTMII=")
677 .unwrap(),
678 name: Some(String::from("[email protected]")),
679 display_name: Some(String::from("John P. Smith")),
680 }),
681 vec![
682 PublicKeyCredentialParameters {
683 alg: COSEAlgorithm::ES256,
684 },
685 PublicKeyCredentialParameters {
686 alg: COSEAlgorithm::RS256,
687 },
688 ],
689 Vec::new(),
690 MakeCredentialsOptions {
691 resident_key: Some(true),
692 user_verification: None,
693 },
694 Default::default(),
695 );
696
697 let mut device = Device::new("commands/make_credentials").unwrap(); // not really used (all functions ignore it)
698 assert_eq!(device.get_protocol(), FidoProtocol::CTAP2);
699 let req_serialized = req
700 .wire_format()
701 .expect("Failed to serialize MakeCredentials request");
702 assert_eq!(req_serialized, MAKE_CREDENTIALS_SAMPLE_REQUEST_CTAP2);
703 let make_cred_result = req
704 .handle_response_ctap2(&mut device, &MAKE_CREDENTIALS_SAMPLE_RESPONSE_CTAP2)
705 .expect("Failed to handle CTAP2 response");
706
707 let expected = MakeCredentialsResult {
708 att_obj: create_attestation_obj(),
709 attachment: AuthenticatorAttachment::Unknown,
710 extensions: Default::default(),
711 };
712
713 assert_eq!(make_cred_result, expected);
714 }
715
716 #[test]
717 fn test_serialize_make_credentials_ctap2_all() {
718 let req = MakeCredentials {
719 client_data_hash: CollectedClientData {
720 webauthn_type: WebauthnType::Create,
721 challenge: Challenge::from(vec![0x00, 0x01, 0x02, 0x03]),
722 origin: String::from("example.com"),
723 cross_origin: true,
724 token_binding: Some(TokenBinding::Present(String::from("AAECAw"))),
725 }
726 .hash()
727 .expect("failed to serialize client data"),
728 rp: RelyingParty {
729 id: String::from("example.com"),
730 name: Some(String::from("Acme")),
731 },
732 user: Some(PublicKeyCredentialUserEntity {
733 id: base64::engine::general_purpose::URL_SAFE
734 .decode("MIIBkzCCATigAwIBAjCCAZMwggE4oAMCAQIwggGTMII=")
735 .unwrap(),
736 name: Some(String::from("[email protected]")),
737 display_name: Some(String::from("John P. Smith")),
738 }),
739 pub_cred_params: vec![
740 PublicKeyCredentialParameters {
741 alg: COSEAlgorithm::ES256,
742 },
743 PublicKeyCredentialParameters {
744 alg: COSEAlgorithm::RS256,
745 },
746 ],
747 exclude_list: vec![PublicKeyCredentialDescriptor {
748 id: vec![4, 5, 6, 7],
749 transports: vec![Transport::USB, Transport::NFC],
750 }],
751 extensions: MakeCredentialsExtensions {
752 cred_props: Some(true),
753 cred_protect: Some(
754 crate::ctap2::server::CredentialProtectionPolicy::UserVerificationRequired,
755 ),
756 hmac_secret: Some(HmacCreateSecretOrPrf::HmacCreateSecret(true)),
757 min_pin_length: Some(true),
758 },
759 options: MakeCredentialsOptions {
760 resident_key: Some(true),
761 user_verification: Some(true),
762 },
763 pin_uv_auth_param: Some({
764 let mut p = PinUvAuthParam::create_empty();
765 p.pin_protocol = PinUvAuthProtocol::try_from(&AuthenticatorInfo {
766 pin_protocols: Some(vec![2]),
767 ..Default::default()
768 })
769 .expect("Failed to create PIN protocol");
770 p
771 }),
772 enterprise_attestation: Some(7),
773 };
774
775 let req_serialized = req
776 .wire_format()
777 .expect("Failed to serialize MakeCredentials request");
778 assert_eq!(
779 req_serialized,
780 [
781 // Value copied from test failure output as regression test snapshot
782 170, 1, 88, 32, 122, 146, 22, 162, 76, 198, 134, 9, 213, 180, 166, 87, 146, 132,
783 116, 119, 180, 172, 60, 27, 146, 142, 207, 8, 158, 125, 4, 28, 226, 254, 21, 122,
784 2, 162, 98, 105, 100, 107, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111, 109, 100,
785 110, 97, 109, 101, 100, 65, 99, 109, 101, 3, 163, 98, 105, 100, 88, 32, 48, 130, 1,
786 147, 48, 130, 1, 56, 160, 3, 2, 1, 2, 48, 130, 1, 147, 48, 130, 1, 56, 160, 3, 2,
787 1, 2, 48, 130, 1, 147, 48, 130, 100, 110, 97, 109, 101, 118, 106, 111, 104, 110,
788 112, 115, 109, 105, 116, 104, 64, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111,
789 109, 107, 100, 105, 115, 112, 108, 97, 121, 78, 97, 109, 101, 109, 74, 111, 104,
790 110, 32, 80, 46, 32, 83, 109, 105, 116, 104, 4, 130, 162, 99, 97, 108, 103, 38,
791 100, 116, 121, 112, 101, 106, 112, 117, 98, 108, 105, 99, 45, 107, 101, 121, 162,
792 99, 97, 108, 103, 57, 1, 0, 100, 116, 121, 112, 101, 106, 112, 117, 98, 108, 105,
793 99, 45, 107, 101, 121, 5, 129, 162, 98, 105, 100, 68, 4, 5, 6, 7, 100, 116, 121,
794 112, 101, 106, 112, 117, 98, 108, 105, 99, 45, 107, 101, 121, 6, 163, 107, 99, 114,
795 101, 100, 80, 114, 111, 116, 101, 99, 116, 3, 107, 104, 109, 97, 99, 45, 115, 101,
796 99, 114, 101, 116, 245, 108, 109, 105, 110, 80, 105, 110, 76, 101, 110, 103, 116,
797 104, 245, 7, 162, 98, 114, 107, 245, 98, 117, 118, 245, 8, 64, 9, 2, 10, 7
798 ]
799 );
800 }
801
802 #[test]
803 fn test_make_credentials_ctap1() {
804 let req = MakeCredentials::new(
805 CollectedClientData {
806 webauthn_type: WebauthnType::Create,
807 challenge: Challenge::new(vec![0x00, 0x01, 0x02, 0x03]),
808 origin: String::from("example.com"),
809 cross_origin: false,
810 token_binding: Some(TokenBinding::Present(String::from("AAECAw"))),
811 }
812 .hash()
813 .expect("failed to serialize client data"),
814 RelyingParty::from("example.com"),
815 Some(PublicKeyCredentialUserEntity {
816 id: base64::engine::general_purpose::URL_SAFE
817 .decode("MIIBkzCCATigAwIBAjCCAZMwggE4oAMCAQIwggGTMII=")
818 .unwrap(),
819 name: Some(String::from("[email protected]")),
820 display_name: Some(String::from("John P. Smith")),
821 }),
822 vec![
823 PublicKeyCredentialParameters {
824 alg: COSEAlgorithm::ES256,
825 },
826 PublicKeyCredentialParameters {
827 alg: COSEAlgorithm::RS256,
828 },
829 ],
830 Vec::new(),
831 MakeCredentialsOptions {
832 resident_key: Some(true),
833 user_verification: None,
834 },
835 Default::default(),
836 );
837
838 let (req_serialized, _) = req
839 .ctap1_format()
840 .expect("Failed to serialize MakeCredentials request");
841 assert_eq!(
842 req_serialized, MAKE_CREDENTIALS_SAMPLE_REQUEST_CTAP1,
843 "\nGot: {req_serialized:X?}\nExpected: {MAKE_CREDENTIALS_SAMPLE_REQUEST_CTAP1:X?}"
844 );
845 let mut device = Device::new("commands/make_credentials").unwrap(); // not really used
846 let make_cred_result = req
847 .handle_response_ctap1(
848 &mut device,
849 Ok(()),
850 &MAKE_CREDENTIALS_SAMPLE_RESPONSE_CTAP1,
851 &(),
852 )
853 .expect("Failed to handle CTAP1 response");
854
855 let att_obj = AttestationObject {
856 auth_data: AuthenticatorData {
857 rp_id_hash: RpIdHash::from(&[
858 0xA3, 0x79, 0xA6, 0xF6, 0xEE, 0xAF, 0xB9, 0xA5, 0x5E, 0x37, 0x8C, 0x11, 0x80,
859 0x34, 0xE2, 0x75, 0x1E, 0x68, 0x2F, 0xAB, 0x9F, 0x2D, 0x30, 0xAB, 0x13, 0xD2,
860 0x12, 0x55, 0x86, 0xCE, 0x19, 0x47,
861 ])
862 .unwrap(),
863 flags: AuthenticatorDataFlags::USER_PRESENT | AuthenticatorDataFlags::ATTESTED,
864 counter: 0,
865 credential_data: Some(AttestedCredentialData {
866 aaguid: AAGuid::default(),
867 credential_id: vec![
868 0x3E, 0xBD, 0x89, 0xBF, 0x77, 0xEC, 0x50, 0x97, 0x55, 0xEE, 0x9C, 0x26,
869 0x35, 0xEF, 0xAA, 0xAC, 0x7B, 0x2B, 0x9C, 0x5C, 0xEF, 0x17, 0x36, 0xC3,
870 0x71, 0x7D, 0xA4, 0x85, 0x34, 0xC8, 0xC6, 0xB6, 0x54, 0xD7, 0xFF, 0x94,
871 0x5F, 0x50, 0xB5, 0xCC, 0x4E, 0x78, 0x05, 0x5B, 0xDD, 0x39, 0x6B, 0x64,
872 0xF7, 0x8D, 0xA2, 0xC5, 0xF9, 0x62, 0x00, 0xCC, 0xD4, 0x15, 0xCD, 0x08,
873 0xFE, 0x42, 0x00, 0x38,
874 ],
875 credential_public_key: COSEKey {
876 alg: COSEAlgorithm::ES256,
877 key: COSEKeyType::EC2(COSEEC2Key {
878 curve: Curve::SECP256R1,
879 x: vec![
880 0xE8, 0x76, 0x25, 0x89, 0x6E, 0xE4, 0xE4, 0x6D, 0xC0, 0x32, 0x76,
881 0x6E, 0x80, 0x87, 0x96, 0x2F, 0x36, 0xDF, 0x9D, 0xFE, 0x8B, 0x56,
882 0x7F, 0x37, 0x63, 0x01, 0x5B, 0x19, 0x90, 0xA6, 0x0E, 0x14,
883 ],
884 y: vec![
885 0x27, 0xDE, 0x61, 0x2D, 0x66, 0x41, 0x8B, 0xDA, 0x19, 0x50, 0x58,
886 0x1E, 0xBC, 0x5C, 0x8C, 0x1D, 0xAD, 0x71, 0x0C, 0xB1, 0x4C, 0x22,
887 0xF8, 0xC9, 0x70, 0x45, 0xF4, 0x61, 0x2F, 0xB2, 0x0C, 0x91,
888 ],
889 }),
890 },
891 }),
892 extensions: Default::default(),
893 },
894 att_stmt: AttestationStatement::FidoU2F(AttestationStatementFidoU2F {
895 sig: Signature(vec![
896 0x30, 0x45, 0x02, 0x20, 0x32, 0x47, 0x79, 0xC6, 0x8F, 0x33, 0x80, 0x28, 0x8A,
897 0x11, 0x97, 0xB6, 0x09, 0x5F, 0x7A, 0x6E, 0xB9, 0xB1, 0xB1, 0xC1, 0x27, 0xF6,
898 0x6A, 0xE1, 0x2A, 0x99, 0xFE, 0x85, 0x32, 0xEC, 0x23, 0xB9, 0x02, 0x21, 0x00,
899 0xE3, 0x95, 0x16, 0xAC, 0x4D, 0x61, 0xEE, 0x64, 0x04, 0x4D, 0x50, 0xB4, 0x15,
900 0xA6, 0xA4, 0xD4, 0xD8, 0x4B, 0xA6, 0xD8, 0x95, 0xCB, 0x5A, 0xB7, 0xA1, 0xAA,
901 0x7D, 0x08, 0x1D, 0xE3, 0x41, 0xFA,
902 ]),
903 attestation_cert: vec![AttestationCertificate(vec![
904 0x30, 0x82, 0x02, 0x4A, 0x30, 0x82, 0x01, 0x32, 0xA0, 0x03, 0x02, 0x01, 0x02,
905 0x02, 0x04, 0x04, 0x6C, 0x88, 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48,
906 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x30, 0x2E, 0x31, 0x2C, 0x30,
907 0x2A, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x23, 0x59, 0x75, 0x62, 0x69, 0x63,
908 0x6F, 0x20, 0x55, 0x32, 0x46, 0x20, 0x52, 0x6F, 0x6F, 0x74, 0x20, 0x43, 0x41,
909 0x20, 0x53, 0x65, 0x72, 0x69, 0x61, 0x6C, 0x20, 0x34, 0x35, 0x37, 0x32, 0x30,
910 0x30, 0x36, 0x33, 0x31, 0x30, 0x20, 0x17, 0x0D, 0x31, 0x34, 0x30, 0x38, 0x30,
911 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5A, 0x18, 0x0F, 0x32, 0x30, 0x35,
912 0x30, 0x30, 0x39, 0x30, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5A, 0x30,
913 0x2C, 0x31, 0x2A, 0x30, 0x28, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x21, 0x59,
914 0x75, 0x62, 0x69, 0x63, 0x6F, 0x20, 0x55, 0x32, 0x46, 0x20, 0x45, 0x45, 0x20,
915 0x53, 0x65, 0x72, 0x69, 0x61, 0x6C, 0x20, 0x32, 0x34, 0x39, 0x31, 0x38, 0x32,
916 0x33, 0x32, 0x34, 0x37, 0x37, 0x30, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A,
917 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D,
918 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x3C, 0xCA, 0xB9, 0x2C, 0xCB, 0x97,
919 0x28, 0x7E, 0xE8, 0xE6, 0x39, 0x43, 0x7E, 0x21, 0xFC, 0xD6, 0xB6, 0xF1, 0x65,
920 0xB2, 0xD5, 0xA3, 0xF3, 0xDB, 0x13, 0x1D, 0x31, 0xC1, 0x6B, 0x74, 0x2B, 0xB4,
921 0x76, 0xD8, 0xD1, 0xE9, 0x90, 0x80, 0xEB, 0x54, 0x6C, 0x9B, 0xBD, 0xF5, 0x56,
922 0xE6, 0x21, 0x0F, 0xD4, 0x27, 0x85, 0x89, 0x9E, 0x78, 0xCC, 0x58, 0x9E, 0xBE,
923 0x31, 0x0F, 0x6C, 0xDB, 0x9F, 0xF4, 0xA3, 0x3B, 0x30, 0x39, 0x30, 0x22, 0x06,
924 0x09, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0xC4, 0x0A, 0x02, 0x04, 0x15, 0x31,
925 0x2E, 0x33, 0x2E, 0x36, 0x2E, 0x31, 0x2E, 0x34, 0x2E, 0x31, 0x2E, 0x34, 0x31,
926 0x34, 0x38, 0x32, 0x2E, 0x31, 0x2E, 0x32, 0x30, 0x13, 0x06, 0x0B, 0x2B, 0x06,
927 0x01, 0x04, 0x01, 0x82, 0xE5, 0x1C, 0x02, 0x01, 0x01, 0x04, 0x04, 0x03, 0x02,
928 0x04, 0x30, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01,
929 0x01, 0x0B, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x9F, 0x9B, 0x05, 0x22,
930 0x48, 0xBC, 0x4C, 0xF4, 0x2C, 0xC5, 0x99, 0x1F, 0xCA, 0xAB, 0xAC, 0x9B, 0x65,
931 0x1B, 0xBE, 0x5B, 0xDC, 0xDC, 0x8E, 0xF0, 0xAD, 0x2C, 0x1C, 0x1F, 0xFB, 0x36,
932 0xD1, 0x87, 0x15, 0xD4, 0x2E, 0x78, 0xB2, 0x49, 0x22, 0x4F, 0x92, 0xC7, 0xE6,
933 0xE7, 0xA0, 0x5C, 0x49, 0xF0, 0xE7, 0xE4, 0xC8, 0x81, 0xBF, 0x2E, 0x94, 0xF4,
934 0x5E, 0x4A, 0x21, 0x83, 0x3D, 0x74, 0x56, 0x85, 0x1D, 0x0F, 0x6C, 0x14, 0x5A,
935 0x29, 0x54, 0x0C, 0x87, 0x4F, 0x30, 0x92, 0xC9, 0x34, 0xB4, 0x3D, 0x22, 0x2B,
936 0x89, 0x62, 0xC0, 0xF4, 0x10, 0xCE, 0xF1, 0xDB, 0x75, 0x89, 0x2A, 0xF1, 0x16,
937 0xB4, 0x4A, 0x96, 0xF5, 0xD3, 0x5A, 0xDE, 0xA3, 0x82, 0x2F, 0xC7, 0x14, 0x6F,
938 0x60, 0x04, 0x38, 0x5B, 0xCB, 0x69, 0xB6, 0x5C, 0x99, 0xE7, 0xEB, 0x69, 0x19,
939 0x78, 0x67, 0x03, 0xC0, 0xD8, 0xCD, 0x41, 0xE8, 0xF7, 0x5C, 0xCA, 0x44, 0xAA,
940 0x8A, 0xB7, 0x25, 0xAD, 0x8E, 0x79, 0x9F, 0xF3, 0xA8, 0x69, 0x6A, 0x6F, 0x1B,
941 0x26, 0x56, 0xE6, 0x31, 0xB1, 0xE4, 0x01, 0x83, 0xC0, 0x8F, 0xDA, 0x53, 0xFA,
942 0x4A, 0x8F, 0x85, 0xA0, 0x56, 0x93, 0x94, 0x4A, 0xE1, 0x79, 0xA1, 0x33, 0x9D,
943 0x00, 0x2D, 0x15, 0xCA, 0xBD, 0x81, 0x00, 0x90, 0xEC, 0x72, 0x2E, 0xF5, 0xDE,
944 0xF9, 0x96, 0x5A, 0x37, 0x1D, 0x41, 0x5D, 0x62, 0x4B, 0x68, 0xA2, 0x70, 0x7C,
945 0xAD, 0x97, 0xBC, 0xDD, 0x17, 0x85, 0xAF, 0x97, 0xE2, 0x58, 0xF3, 0x3D, 0xF5,
946 0x6A, 0x03, 0x1A, 0xA0, 0x35, 0x6D, 0x8E, 0x8D, 0x5E, 0xBC, 0xAD, 0xC7, 0x4E,
947 0x07, 0x16, 0x36, 0xC6, 0xB1, 0x10, 0xAC, 0xE5, 0xCC, 0x9B, 0x90, 0xDF, 0xEA,
948 0xCA, 0xE6, 0x40, 0xFF, 0x1B, 0xB0, 0xF1, 0xFE, 0x5D, 0xB4, 0xEF, 0xF7, 0xA9,
949 0x5F, 0x06, 0x07, 0x33, 0xF5,
950 ])],
951 }),
952 };
953
954 let expected = MakeCredentialsResult {
955 att_obj,
956 attachment: AuthenticatorAttachment::Unknown,
957 extensions: Default::default(),
958 };
959
960 assert_eq!(make_cred_result, expected);
961 }
962
963 // This includes a CTAP2 encoded attestation object that is identical to
964 // the WebAuthn encoded attestation object in `ctap2::attestation::test::SAMPLE_ATTESTATION`.
965 // Both values decode to `ctap2::attestation::test::create_attestation_obj`.
966 #[rustfmt::skip]
967 pub const MAKE_CREDENTIALS_SAMPLE_RESPONSE_CTAP2: [u8; 660] = [
968 0x00, // status = success
969 0xa3, // map(3)
970 0x01, // unsigned(1)
971 0x66, // text(6)
972 0x70, 0x61, 0x63, 0x6b, 0x65, 0x64, // "packed"
973 0x02, // unsigned(2)
974 0x58, 0x94, // bytes(148)
975 // authData
976 0xc2, 0x89, 0xc5, 0xca, 0x9b, 0x04, 0x60, 0xf9, 0x34, 0x6a, 0xb4, 0xe4, 0x2d, 0x84, 0x27, // rp_id_hash
977 0x43, 0x40, 0x4d, 0x31, 0xf4, 0x84, 0x68, 0x25, 0xa6, 0xd0, 0x65, 0xbe, 0x59, 0x7a, 0x87, // rp_id_hash
978 0x05, 0x1d, // rp_id_hash
979 0x41, // authData Flags
980 0x00, 0x00, 0x00, 0x0b, // authData counter
981 0xf8, 0xa0, 0x11, 0xf3, 0x8c, 0x0a, 0x4d, 0x15, 0x80, 0x06, 0x17, 0x11, 0x1f, 0x9e, 0xdc, 0x7d, // AAGUID
982 0x00, 0x10, // credential id length
983 0x89, 0x59, 0xce, 0xad, 0x5b, 0x5c, 0x48, 0x16, 0x4e, 0x8a, 0xbc, 0xd6, 0xd9, 0x43, 0x5c, 0x6f, // credential id
984 // credential public key
985 0xa5, 0x01, 0x02, 0x03, 0x26, 0x20, 0x01, 0x21, 0x58, 0x20, 0xa5, 0xfd, 0x5c, 0xe1, 0xb1, 0xc4,
986 0x58, 0xc5, 0x30, 0xa5, 0x4f, 0xa6, 0x1b, 0x31, 0xbf, 0x6b, 0x04, 0xbe, 0x8b, 0x97, 0xaf, 0xde,
987 0x54, 0xdd, 0x8c, 0xbb, 0x69, 0x27, 0x5a, 0x8a, 0x1b, 0xe1, 0x22, 0x58, 0x20, 0xfa, 0x3a, 0x32,
988 0x31, 0xdd, 0x9d, 0xee, 0xd9, 0xd1, 0x89, 0x7b, 0xe5, 0xa6, 0x22, 0x8c, 0x59, 0x50, 0x1e, 0x4b,
989 0xcd, 0x12, 0x97, 0x5d, 0x3d, 0xff, 0x73, 0x0f, 0x01, 0x27, 0x8e, 0xa6, 0x1c,
990 0x03, // unsigned(3)
991 0xa3, // map(3)
992 0x63, // text(3)
993 0x61, 0x6c, 0x67, // "alg"
994 0x26, // -7 (ES256)
995 0x63, // text(3)
996 0x73, 0x69, 0x67, // "sig"
997 0x58, 0x47, // bytes(71)
998 0x30, 0x45, 0x02, 0x20, 0x13, 0xf7, 0x3c, 0x5d, 0x9d, 0x53, 0x0e, 0x8c, 0xc1, 0x5c, 0xc9, // signature
999 0xbd, 0x96, 0xad, 0x58, 0x6d, 0x39, 0x36, 0x64, 0xe4, 0x62, 0xd5, 0xf0, 0x56, 0x12, 0x35, // ..
1000 0xe6, 0x35, 0x0f, 0x2b, 0x72, 0x89, 0x02, 0x21, 0x00, 0x90, 0x35, 0x7f, 0xf9, 0x10, 0xcc, // ..
1001 0xb5, 0x6a, 0xc5, 0xb5, 0x96, 0x51, 0x19, 0x48, 0x58, 0x1c, 0x8f, 0xdd, 0xb4, 0xa2, 0xb7, // ..
1002 0x99, 0x59, 0x94, 0x80, 0x78, 0xb0, 0x9f, 0x4b, 0xdc, 0x62, 0x29, // ..
1003 0x63, // text(3)
1004 0x78, 0x35, 0x63, // "x5c"
1005 0x81, // array(1)
1006 0x59, 0x01, 0x97, // bytes(407)
1007 0x30, 0x82, 0x01, 0x93, 0x30, 0x82, 0x01, //certificate...
1008 0x38, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0x85, 0x9b, 0x72, 0x6c, 0xb2, 0x4b,
1009 0x4c, 0x29, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30,
1010 0x47, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31,
1011 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0b, 0x59, 0x75, 0x62, 0x69, 0x63,
1012 0x6f, 0x20, 0x54, 0x65, 0x73, 0x74, 0x31, 0x22, 0x30, 0x20, 0x06, 0x03, 0x55, 0x04, 0x0b,
1013 0x0c, 0x19, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72,
1014 0x20, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x30, 0x1e, 0x17,
1015 0x0d, 0x31, 0x36, 0x31, 0x32, 0x30, 0x34, 0x31, 0x31, 0x35, 0x35, 0x30, 0x30, 0x5a, 0x17,
1016 0x0d, 0x32, 0x36, 0x31, 0x32, 0x30, 0x32, 0x31, 0x31, 0x35, 0x35, 0x30, 0x30, 0x5a, 0x30,
1017 0x47, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31,
1018 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0b, 0x59, 0x75, 0x62, 0x69, 0x63,
1019 0x6f, 0x20, 0x54, 0x65, 0x73, 0x74, 0x31, 0x22, 0x30, 0x20, 0x06, 0x03, 0x55, 0x04, 0x0b,
1020 0x0c, 0x19, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72,
1021 0x20, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x30, 0x59, 0x30,
1022 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48,
1023 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xad, 0x11, 0xeb, 0x0e, 0x88, 0x52,
1024 0xe5, 0x3a, 0xd5, 0xdf, 0xed, 0x86, 0xb4, 0x1e, 0x61, 0x34, 0xa1, 0x8e, 0xc4, 0xe1, 0xaf,
1025 0x8f, 0x22, 0x1a, 0x3c, 0x7d, 0x6e, 0x63, 0x6c, 0x80, 0xea, 0x13, 0xc3, 0xd5, 0x04, 0xff,
1026 0x2e, 0x76, 0x21, 0x1b, 0xb4, 0x45, 0x25, 0xb1, 0x96, 0xc4, 0x4c, 0xb4, 0x84, 0x99, 0x79,
1027 0xcf, 0x6f, 0x89, 0x6e, 0xcd, 0x2b, 0xb8, 0x60, 0xde, 0x1b, 0xf4, 0x37, 0x6b, 0xa3, 0x0d,
1028 0x30, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x0a,
1029 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x49, 0x00, 0x30, 0x46,
1030 0x02, 0x21, 0x00, 0xe9, 0xa3, 0x9f, 0x1b, 0x03, 0x19, 0x75, 0x25, 0xf7, 0x37, 0x3e, 0x10,
1031 0xce, 0x77, 0xe7, 0x80, 0x21, 0x73, 0x1b, 0x94, 0xd0, 0xc0, 0x3f, 0x3f, 0xda, 0x1f, 0xd2,
1032 0x2d, 0xb3, 0xd0, 0x30, 0xe7, 0x02, 0x21, 0x00, 0xc4, 0xfa, 0xec, 0x34, 0x45, 0xa8, 0x20,
1033 0xcf, 0x43, 0x12, 0x9c, 0xdb, 0x00, 0xaa, 0xbe, 0xfd, 0x9a, 0xe2, 0xd8, 0x74, 0xf9, 0xc5,
1034 0xd3, 0x43, 0xcb, 0x2f, 0x11, 0x3d, 0xa2, 0x37, 0x23, 0xf3,
1035 ];
1036
1037 #[rustfmt::skip]
1038 pub const MAKE_CREDENTIALS_SAMPLE_REQUEST_CTAP2: [u8; 210] = [
1039 // NOTE: This has been taken from CTAP2.0 spec, but the clientDataHash has been replaced
1040 // to be able to operate with known values for CollectedClientData (spec doesn't say
1041 // what values led to the provided example hash (see client_data.rs))
1042 0xa5, // map(5)
1043 0x01, // unsigned(1) - clientDataHash
1044 0x58, 0x20, // bytes(32)
1045 0x75, 0x35, 0x35, 0x7d, 0x49, 0x6e, 0x33, 0xc8, 0x18, 0x7f, 0xea, 0x8d, 0x11, // hash
1046 0x32, 0x64, 0xaa, 0xa4, 0x52, 0x3e, 0x13, 0x40, 0x14, 0x9f, 0xbe, 0x00, 0x3f, // hash
1047 0x10, 0x87, 0x54, 0xc3, 0x2d, 0x80, // hash
1048 0x02, // unsigned(2) - rp
1049 0xa2, // map(2) Replace line below with this one, once RelyingParty supports "name"
1050 0x62, // text(2)
1051 0x69, 0x64, // "id"
1052 0x6b, // text(11)
1053 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, // "example.com"
1054 0x64, // text(4)
1055 0x6e, 0x61, 0x6d, 0x65, // "name"
1056 0x64, // text(4)
1057 0x41, 0x63, 0x6d, 0x65, // "Acme"
1058 0x03, // unsigned(3) - user
1059 0xa3, // map(3)
1060 0x62, // text(2)
1061 0x69, 0x64, // "id"
1062 0x58, 0x20, // bytes(32)
1063 0x30, 0x82, 0x01, 0x93, 0x30, 0x82, 0x01, 0x38, 0xa0, 0x03, 0x02, 0x01, 0x02, // userid
1064 0x30, 0x82, 0x01, 0x93, 0x30, 0x82, 0x01, 0x38, 0xa0, 0x03, 0x02, 0x01, 0x02, // ...
1065 0x30, 0x82, 0x01, 0x93, 0x30, 0x82, // ...
1066 0x64, // text(4)
1067 0x6e, 0x61, 0x6d, 0x65, // "name"
1068 0x76, // text(22)
1069 0x6a, 0x6f, 0x68, 0x6e, 0x70, 0x73, 0x6d, 0x69, 0x74, // "[email protected]"
1070 0x68, 0x40, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, // ...
1071 0x6b, // text(11)
1072 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, // "displayName"
1073 0x6d, // text(13)
1074 0x4a, 0x6f, 0x68, 0x6e, 0x20, 0x50, 0x2e, 0x20, 0x53, 0x6d, 0x69, 0x74, 0x68, // "John P. Smith"
1075 0x04, // unsigned(4) - pubKeyCredParams
1076 0x82, // array(2)
1077 0xa2, // map(2)
1078 0x63, // text(3)
1079 0x61, 0x6c, 0x67, // "alg"
1080 0x26, // -7 (ES256)
1081 0x64, // text(4)
1082 0x74, 0x79, 0x70, 0x65, // "type"
1083 0x6a, // text(10)
1084 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x2D, 0x6B, 0x65, 0x79, // "public-key"
1085 0xa2, // map(2)
1086 0x63, // text(3)
1087 0x61, 0x6c, 0x67, // "alg"
1088 0x39, 0x01, 0x00, // -257 (RS256)
1089 0x64, // text(4)
1090 0x74, 0x79, 0x70, 0x65, // "type"
1091 0x6a, // text(10)
1092 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x2D, 0x6B, 0x65, 0x79, // "public-key"
1093 // TODO(MS): Options seem to be parsed differently than in the example here.
1094 0x07, // unsigned(7) - options
1095 0xa1, // map(1)
1096 0x62, // text(2)
1097 0x72, 0x6b, // "rk"
1098 0xf5, // primitive(21)
1099 ];
1100
1101 pub const MAKE_CREDENTIALS_SAMPLE_REQUEST_CTAP1: [u8; 73] = [
1102 // CBOR Header
1103 0x0, // CLA
1104 0x1, // INS U2F_Register
1105 0x3, // P1 Flags
1106 0x0, // P2
1107 0x0, 0x0, 0x40, // Lc
1108 // NOTE: This has been taken from CTAP2.0 spec, but the clientDataHash has been replaced
1109 // to be able to operate with known values for CollectedClientData (spec doesn't say
1110 // what values led to the provided example hash)
1111 // clientDataHash:
1112 0x75, 0x35, 0x35, 0x7d, 0x49, 0x6e, 0x33, 0xc8, 0x18, 0x7f, 0xea, 0x8d, 0x11, // hash
1113 0x32, 0x64, 0xaa, 0xa4, 0x52, 0x3e, 0x13, 0x40, 0x14, 0x9f, 0xbe, 0x00, 0x3f, // hash
1114 0x10, 0x87, 0x54, 0xc3, 0x2d, 0x80, // hash
1115 // rpIdHash:
1116 0xA3, 0x79, 0xA6, 0xF6, 0xEE, 0xAF, 0xB9, 0xA5, 0x5E, 0x37, 0x8C, 0x11, 0x80, 0x34, 0xE2,
1117 0x75, 0x1E, 0x68, 0x2F, 0xAB, 0x9F, 0x2D, 0x30, 0xAB, 0x13, 0xD2, 0x12, 0x55, 0x86, 0xCE,
1118 0x19, 0x47, // ..
1119 // Le (Ne=65536):
1120 0x0, 0x0,
1121 ];
1122
1123 pub const MAKE_CREDENTIALS_SAMPLE_RESPONSE_CTAP1: [u8; 792] = [
1124 0x05, // Reserved Byte (1 Byte)
1125 // User Public Key (65 Bytes)
1126 0x04, 0xE8, 0x76, 0x25, 0x89, 0x6E, 0xE4, 0xE4, 0x6D, 0xC0, 0x32, 0x76, 0x6E, 0x80, 0x87,
1127 0x96, 0x2F, 0x36, 0xDF, 0x9D, 0xFE, 0x8B, 0x56, 0x7F, 0x37, 0x63, 0x01, 0x5B, 0x19, 0x90,
1128 0xA6, 0x0E, 0x14, 0x27, 0xDE, 0x61, 0x2D, 0x66, 0x41, 0x8B, 0xDA, 0x19, 0x50, 0x58, 0x1E,
1129 0xBC, 0x5C, 0x8C, 0x1D, 0xAD, 0x71, 0x0C, 0xB1, 0x4C, 0x22, 0xF8, 0xC9, 0x70, 0x45, 0xF4,
1130 0x61, 0x2F, 0xB2, 0x0C, 0x91, // ...
1131 0x40, // Key Handle Length (1 Byte)
1132 // Key Handle (Key Handle Length Bytes)
1133 0x3E, 0xBD, 0x89, 0xBF, 0x77, 0xEC, 0x50, 0x97, 0x55, 0xEE, 0x9C, 0x26, 0x35, 0xEF, 0xAA,
1134 0xAC, 0x7B, 0x2B, 0x9C, 0x5C, 0xEF, 0x17, 0x36, 0xC3, 0x71, 0x7D, 0xA4, 0x85, 0x34, 0xC8,
1135 0xC6, 0xB6, 0x54, 0xD7, 0xFF, 0x94, 0x5F, 0x50, 0xB5, 0xCC, 0x4E, 0x78, 0x05, 0x5B, 0xDD,
1136 0x39, 0x6B, 0x64, 0xF7, 0x8D, 0xA2, 0xC5, 0xF9, 0x62, 0x00, 0xCC, 0xD4, 0x15, 0xCD, 0x08,
1137 0xFE, 0x42, 0x00, 0x38, // ...
1138 // X.509 Cert (Variable length Cert)
1139 0x30, 0x82, 0x02, 0x4A, 0x30, 0x82, 0x01, 0x32, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x04,
1140 0x04, 0x6C, 0x88, 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01,
1141 0x01, 0x0B, 0x05, 0x00, 0x30, 0x2E, 0x31, 0x2C, 0x30, 0x2A, 0x06, 0x03, 0x55, 0x04, 0x03,
1142 0x13, 0x23, 0x59, 0x75, 0x62, 0x69, 0x63, 0x6F, 0x20, 0x55, 0x32, 0x46, 0x20, 0x52, 0x6F,
1143 0x6F, 0x74, 0x20, 0x43, 0x41, 0x20, 0x53, 0x65, 0x72, 0x69, 0x61, 0x6C, 0x20, 0x34, 0x35,
1144 0x37, 0x32, 0x30, 0x30, 0x36, 0x33, 0x31, 0x30, 0x20, 0x17, 0x0D, 0x31, 0x34, 0x30, 0x38,
1145 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5A, 0x18, 0x0F, 0x32, 0x30, 0x35, 0x30,
1146 0x30, 0x39, 0x30, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5A, 0x30, 0x2C, 0x31, 0x2A,
1147 0x30, 0x28, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x21, 0x59, 0x75, 0x62, 0x69, 0x63, 0x6F,
1148 0x20, 0x55, 0x32, 0x46, 0x20, 0x45, 0x45, 0x20, 0x53, 0x65, 0x72, 0x69, 0x61, 0x6C, 0x20,
1149 0x32, 0x34, 0x39, 0x31, 0x38, 0x32, 0x33, 0x32, 0x34, 0x37, 0x37, 0x30, 0x30, 0x59, 0x30,
1150 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06, 0x08, 0x2A, 0x86, 0x48,
1151 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x3C, 0xCA, 0xB9, 0x2C, 0xCB, 0x97,
1152 0x28, 0x7E, 0xE8, 0xE6, 0x39, 0x43, 0x7E, 0x21, 0xFC, 0xD6, 0xB6, 0xF1, 0x65, 0xB2, 0xD5,
1153 0xA3, 0xF3, 0xDB, 0x13, 0x1D, 0x31, 0xC1, 0x6B, 0x74, 0x2B, 0xB4, 0x76, 0xD8, 0xD1, 0xE9,
1154 0x90, 0x80, 0xEB, 0x54, 0x6C, 0x9B, 0xBD, 0xF5, 0x56, 0xE6, 0x21, 0x0F, 0xD4, 0x27, 0x85,
1155 0x89, 0x9E, 0x78, 0xCC, 0x58, 0x9E, 0xBE, 0x31, 0x0F, 0x6C, 0xDB, 0x9F, 0xF4, 0xA3, 0x3B,
1156 0x30, 0x39, 0x30, 0x22, 0x06, 0x09, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0xC4, 0x0A, 0x02,
1157 0x04, 0x15, 0x31, 0x2E, 0x33, 0x2E, 0x36, 0x2E, 0x31, 0x2E, 0x34, 0x2E, 0x31, 0x2E, 0x34,
1158 0x31, 0x34, 0x38, 0x32, 0x2E, 0x31, 0x2E, 0x32, 0x30, 0x13, 0x06, 0x0B, 0x2B, 0x06, 0x01,
1159 0x04, 0x01, 0x82, 0xE5, 0x1C, 0x02, 0x01, 0x01, 0x04, 0x04, 0x03, 0x02, 0x04, 0x30, 0x30,
1160 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x03,
1161 0x82, 0x01, 0x01, 0x00, 0x9F, 0x9B, 0x05, 0x22, 0x48, 0xBC, 0x4C, 0xF4, 0x2C, 0xC5, 0x99,
1162 0x1F, 0xCA, 0xAB, 0xAC, 0x9B, 0x65, 0x1B, 0xBE, 0x5B, 0xDC, 0xDC, 0x8E, 0xF0, 0xAD, 0x2C,
1163 0x1C, 0x1F, 0xFB, 0x36, 0xD1, 0x87, 0x15, 0xD4, 0x2E, 0x78, 0xB2, 0x49, 0x22, 0x4F, 0x92,
1164 0xC7, 0xE6, 0xE7, 0xA0, 0x5C, 0x49, 0xF0, 0xE7, 0xE4, 0xC8, 0x81, 0xBF, 0x2E, 0x94, 0xF4,
1165 0x5E, 0x4A, 0x21, 0x83, 0x3D, 0x74, 0x56, 0x85, 0x1D, 0x0F, 0x6C, 0x14, 0x5A, 0x29, 0x54,
1166 0x0C, 0x87, 0x4F, 0x30, 0x92, 0xC9, 0x34, 0xB4, 0x3D, 0x22, 0x2B, 0x89, 0x62, 0xC0, 0xF4,
1167 0x10, 0xCE, 0xF1, 0xDB, 0x75, 0x89, 0x2A, 0xF1, 0x16, 0xB4, 0x4A, 0x96, 0xF5, 0xD3, 0x5A,
1168 0xDE, 0xA3, 0x82, 0x2F, 0xC7, 0x14, 0x6F, 0x60, 0x04, 0x38, 0x5B, 0xCB, 0x69, 0xB6, 0x5C,
1169 0x99, 0xE7, 0xEB, 0x69, 0x19, 0x78, 0x67, 0x03, 0xC0, 0xD8, 0xCD, 0x41, 0xE8, 0xF7, 0x5C,
1170 0xCA, 0x44, 0xAA, 0x8A, 0xB7, 0x25, 0xAD, 0x8E, 0x79, 0x9F, 0xF3, 0xA8, 0x69, 0x6A, 0x6F,
1171 0x1B, 0x26, 0x56, 0xE6, 0x31, 0xB1, 0xE4, 0x01, 0x83, 0xC0, 0x8F, 0xDA, 0x53, 0xFA, 0x4A,
1172 0x8F, 0x85, 0xA0, 0x56, 0x93, 0x94, 0x4A, 0xE1, 0x79, 0xA1, 0x33, 0x9D, 0x00, 0x2D, 0x15,
1173 0xCA, 0xBD, 0x81, 0x00, 0x90, 0xEC, 0x72, 0x2E, 0xF5, 0xDE, 0xF9, 0x96, 0x5A, 0x37, 0x1D,
1174 0x41, 0x5D, 0x62, 0x4B, 0x68, 0xA2, 0x70, 0x7C, 0xAD, 0x97, 0xBC, 0xDD, 0x17, 0x85, 0xAF,
1175 0x97, 0xE2, 0x58, 0xF3, 0x3D, 0xF5, 0x6A, 0x03, 0x1A, 0xA0, 0x35, 0x6D, 0x8E, 0x8D, 0x5E,
1176 0xBC, 0xAD, 0xC7, 0x4E, 0x07, 0x16, 0x36, 0xC6, 0xB1, 0x10, 0xAC, 0xE5, 0xCC, 0x9B, 0x90,
1177 0xDF, 0xEA, 0xCA, 0xE6, 0x40, 0xFF, 0x1B, 0xB0, 0xF1, 0xFE, 0x5D, 0xB4, 0xEF, 0xF7, 0xA9,
1178 0x5F, 0x06, 0x07, 0x33, 0xF5, // ...
1179 // Signature (variable Length)
1180 0x30, 0x45, 0x02, 0x20, 0x32, 0x47, 0x79, 0xC6, 0x8F, 0x33, 0x80, 0x28, 0x8A, 0x11, 0x97,
1181 0xB6, 0x09, 0x5F, 0x7A, 0x6E, 0xB9, 0xB1, 0xB1, 0xC1, 0x27, 0xF6, 0x6A, 0xE1, 0x2A, 0x99,
1182 0xFE, 0x85, 0x32, 0xEC, 0x23, 0xB9, 0x02, 0x21, 0x00, 0xE3, 0x95, 0x16, 0xAC, 0x4D, 0x61,
1183 0xEE, 0x64, 0x04, 0x4D, 0x50, 0xB4, 0x15, 0xA6, 0xA4, 0xD4, 0xD8, 0x4B, 0xA6, 0xD8, 0x95,
1184 0xCB, 0x5A, 0xB7, 0xA1, 0xAA, 0x7D, 0x08, 0x1D, 0xE3, 0x41, 0xFA, // ...
1185 ];
1186 }