| 1 | // Copyright (c) 2018, Yubico AB | |
| 2 | // All rights reserved. | |
| 3 | // | |
| 4 | // Redistribution and use in source and binary forms, with or without | |
| 5 | // modification, are permitted provided that the following conditions are met: | |
| 6 | // | |
| 7 | // 1. Redistributions of source code must retain the above copyright notice, this | |
| 8 | // list of conditions and the following disclaimer. | |
| 9 | // | |
| 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, | |
| 11 | // this list of conditions and the following disclaimer in the documentation | |
| 12 | // and/or other materials provided with the distribution. | |
| 13 | // | |
| 14 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
| 15 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 16 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 17 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |
| 18 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
| 19 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| 20 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
| 21 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
| 22 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 23 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 | ||
| 25 | package com.yubico.webauthn; | |
| 26 | ||
| 27 | import com.fasterxml.jackson.annotation.JsonAlias; | |
| 28 | import com.fasterxml.jackson.annotation.JsonCreator; | |
| 29 | import com.fasterxml.jackson.annotation.JsonIgnore; | |
| 30 | import com.fasterxml.jackson.annotation.JsonProperty; | |
| 31 | import com.yubico.webauthn.data.AttestedCredentialData; | |
| 32 | import com.yubico.webauthn.data.AuthenticatorAssertionResponse; | |
| 33 | import com.yubico.webauthn.data.AuthenticatorAttestationResponse; | |
| 34 | import com.yubico.webauthn.data.AuthenticatorData; | |
| 35 | import com.yubico.webauthn.data.AuthenticatorTransport; | |
| 36 | import com.yubico.webauthn.data.ByteArray; | |
| 37 | import com.yubico.webauthn.data.COSEAlgorithmIdentifier; | |
| 38 | import com.yubico.webauthn.data.PublicKeyCredentialCreationOptions; | |
| 39 | import com.yubico.webauthn.data.PublicKeyCredentialDescriptor; | |
| 40 | import com.yubico.webauthn.data.PublicKeyCredentialRequestOptions; | |
| 41 | import com.yubico.webauthn.data.UserIdentity; | |
| 42 | import java.io.IOException; | |
| 43 | import java.security.NoSuchAlgorithmException; | |
| 44 | import java.security.PublicKey; | |
| 45 | import java.security.spec.InvalidKeySpecException; | |
| 46 | import java.util.Optional; | |
| 47 | import java.util.Set; | |
| 48 | import lombok.AccessLevel; | |
| 49 | import lombok.Builder; | |
| 50 | import lombok.Getter; | |
| 51 | import lombok.NonNull; | |
| 52 | import lombok.Value; | |
| 53 | ||
| 54 | /** | |
| 55 | * An abstraction of a credential registered to a particular user. | |
| 56 | * | |
| 57 | * <p>Instances of this class are not expected to be long-lived, and the library only needs to read | |
| 58 | * them, never write them. You may at your discretion store them directly in your database, or | |
| 59 | * assemble them from other components. | |
| 60 | */ | |
| 61 | @Value | |
| 62 | @Builder(toBuilder = true) | |
| 63 | public final class RegisteredCredential implements CredentialRecord { | |
| 64 | ||
| 65 | /** | |
| 66 | * The <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#credential-id">credential | |
| 67 | * ID</a> of the credential. | |
| 68 | * | |
| 69 | * @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#credential-id">Credential | |
| 70 | * ID</a> | |
| 71 | * @see RegistrationResult#getKeyId() | |
| 72 | * @see PublicKeyCredentialDescriptor#getId() | |
| 73 | */ | |
| 74 | @NonNull private final ByteArray credentialId; | |
| 75 | ||
| 76 | /** | |
| 77 | * The <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#user-handle">user handle</a> | |
| 78 | * of the user the credential is registered to. | |
| 79 | * | |
| 80 | * @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#user-handle">User Handle</a> | |
| 81 | * @see UserIdentity#getId() | |
| 82 | */ | |
| 83 | @NonNull private final ByteArray userHandle; | |
| 84 | ||
| 85 | /** | |
| 86 | * The credential public key encoded in COSE_Key format, as defined in Section 7 of <a | |
| 87 | * href="https://tools.ietf.org/html/rfc8152">RFC 8152</a>. | |
| 88 | * | |
| 89 | * <p>This is used to verify the {@link AuthenticatorAssertionResponse#getSignature() signature} | |
| 90 | * in authentication assertions. | |
| 91 | * | |
| 92 | * @see AttestedCredentialData#getCredentialPublicKey() | |
| 93 | * @see RegistrationResult#getPublicKeyCose() | |
| 94 | */ | |
| 95 | @NonNull private final ByteArray publicKeyCose; | |
| 96 | ||
| 97 | /** | |
| 98 | * The public key of the credential, parsed as a {@link PublicKey} object. | |
| 99 | * | |
| 100 | * @see #getPublicKeyCose() | |
| 101 | * @see RegistrationResult#getParsedPublicKey() | |
| 102 | */ | |
| 103 | @NonNull | |
| 104 | @JsonIgnore | |
| 105 | public PublicKey getParsedPublicKey() | |
| 106 | throws InvalidKeySpecException, NoSuchAlgorithmException, IOException { | |
| 107 |
1
1. getParsedPublicKey : replaced return value with null for com/yubico/webauthn/RegisteredCredential::getParsedPublicKey → NO_COVERAGE |
return WebAuthnCodecs.importCosePublicKey(getPublicKeyCose()); |
| 108 | } | |
| 109 | ||
| 110 | /** | |
| 111 | * The stored <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#signcount">signature | |
| 112 | * count</a> of the credential. | |
| 113 | * | |
| 114 | * <p>This is used to validate the {@link AuthenticatorData#getSignatureCounter() signature | |
| 115 | * counter} in authentication assertions. | |
| 116 | * | |
| 117 | * @see <a | |
| 118 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-authenticator-data">§6.1. | |
| 119 | * Authenticator Data</a> | |
| 120 | * @see AuthenticatorData#getSignatureCounter() | |
| 121 | * @see AssertionResult#getSignatureCount() | |
| 122 | */ | |
| 123 | @Builder.Default private final long signatureCount = 0; | |
| 124 | ||
| 125 | /** | |
| 126 | * Transport hints as to how the client might communicate with the authenticator this credential | |
| 127 | * is bound to. | |
| 128 | * | |
| 129 | * <p>This SHOULD be set to the value returned by {@link | |
| 130 | * AuthenticatorAttestationResponse#getTransports()} when the credential was created. That value | |
| 131 | * SHOULD NOT be modified. | |
| 132 | * | |
| 133 | * <p>This is only used if the {@link RelyingParty} is configured with a {@link | |
| 134 | * CredentialRepositoryV2}, in which case this is used to set {@link | |
| 135 | * PublicKeyCredentialDescriptor#getTransports()} in {@link | |
| 136 | * PublicKeyCredentialCreationOptions#getExcludeCredentials() excludeCredentials} in {@link | |
| 137 | * RelyingParty#startRegistration(StartRegistrationOptions)} and {@link | |
| 138 | * PublicKeyCredentialRequestOptions#getAllowCredentials() allowCredentials} in {@link | |
| 139 | * RelyingParty#startAssertion(StartAssertionOptions)}. This is not used if the {@link | |
| 140 | * RelyingParty} is configured with a {@link CredentialRepository}. | |
| 141 | * | |
| 142 | * @see <a | |
| 143 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#dom-authenticatorattestationresponse-gettransports">getTransports() | |
| 144 | * in 5.2.1. Information About Public Key Credential (interface | |
| 145 | * AuthenticatorAttestationResponse)</a> | |
| 146 | * @see <a | |
| 147 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#dom-publickeycredentialdescriptor-transports">transports | |
| 148 | * in 5.8.3. Credential Descriptor (dictionary PublicKeyCredentialDescriptor)</a> | |
| 149 | * @see AuthenticatorAttestationResponse#getTransports() | |
| 150 | * @see PublicKeyCredentialDescriptor#getTransports() | |
| 151 | * @deprecated EXPERIMENTAL: This is an experimental feature. It is likely to change or be deleted | |
| 152 | * before reaching a mature release. | |
| 153 | */ | |
| 154 | @Deprecated @Builder.Default private final Set<AuthenticatorTransport> transports = null; | |
| 155 | ||
| 156 | /** | |
| 157 | * The state of the <a href="https://w3c.github.io/webauthn/#authdata-flags-be">BE flag</a> when | |
| 158 | * this credential was registered, if known. | |
| 159 | * | |
| 160 | * <p>If absent, it is not known whether or not this credential is backup eligible. | |
| 161 | * | |
| 162 | * <p>If present and <code>true</code>, the credential is backup eligible: it can be backed up in | |
| 163 | * some way, most commonly by syncing the private key to a cloud account. | |
| 164 | * | |
| 165 | * <p>If present and <code>false</code>, the credential is not backup eligible: it cannot be | |
| 166 | * backed up in any way. | |
| 167 | * | |
| 168 | * <p>{@link CredentialRepository} implementations SHOULD set this to the first known value | |
| 169 | * returned by {@link RegistrationResult#isBackupEligible()} or {@link | |
| 170 | * AssertionResult#isBackupEligible()}, if known. If unknown, {@link CredentialRepository} | |
| 171 | * implementations SHOULD set this to <code>null</code> or not set this value. | |
| 172 | * | |
| 173 | * @deprecated EXPERIMENTAL: This feature is from a not yet mature standard; it could change as | |
| 174 | * the standard matures. | |
| 175 | */ | |
| 176 | @Deprecated | |
| 177 | @Getter(AccessLevel.NONE) | |
| 178 | @Builder.Default | |
| 179 | private final Boolean backupEligible = null; | |
| 180 | ||
| 181 | /** | |
| 182 | * The last known state of the <a href="https://w3c.github.io/webauthn/#authdata-flags-bs">BS | |
| 183 | * flag</a> for this credential, if known. | |
| 184 | * | |
| 185 | * <p>If absent, the backup state of the credential is not known. | |
| 186 | * | |
| 187 | * <p>If present and <code>true</code>, the credential is believed to be currently backed up. | |
| 188 | * | |
| 189 | * <p>If present and <code>false</code>, the credential is believed to not be currently backed up. | |
| 190 | * | |
| 191 | * <p>{@link CredentialRepository} implementations SHOULD set this to the most recent value | |
| 192 | * returned by {@link AssertionResult#isBackedUp()} or {@link RegistrationResult#isBackedUp()}, if | |
| 193 | * known. If unknown, {@link CredentialRepository} implementations SHOULD set this to <code>null | |
| 194 | * </code> or not set this value. | |
| 195 | * | |
| 196 | * @deprecated EXPERIMENTAL: This feature is from a not yet mature standard; it could change as | |
| 197 | * the standard matures. | |
| 198 | */ | |
| 199 | @Deprecated | |
| 200 | @Getter(AccessLevel.NONE) | |
| 201 | @Builder.Default | |
| 202 | private final Boolean backupState = null; | |
| 203 | ||
| 204 | @JsonCreator | |
| 205 | private RegisteredCredential( | |
| 206 |
1
1. <init> : negated conditional → KILLED |
@NonNull @JsonProperty("credentialId") ByteArray credentialId, |
| 207 |
1
1. <init> : negated conditional → KILLED |
@NonNull @JsonProperty("userHandle") ByteArray userHandle, |
| 208 |
1
1. <init> : negated conditional → KILLED |
@NonNull @JsonProperty("publicKeyCose") ByteArray publicKeyCose, |
| 209 | @JsonProperty("signatureCount") long signatureCount, | |
| 210 | @JsonProperty("transports") Set<AuthenticatorTransport> transports, | |
| 211 | @JsonProperty("backupEligible") Boolean backupEligible, | |
| 212 | @JsonProperty("backupState") @JsonAlias("backedUp") Boolean backupState) { | |
| 213 | this.credentialId = credentialId; | |
| 214 | this.userHandle = userHandle; | |
| 215 | this.publicKeyCose = publicKeyCose; | |
| 216 | this.signatureCount = signatureCount; | |
| 217 | this.transports = transports; | |
| 218 | this.backupEligible = backupEligible; | |
| 219 | this.backupState = backupState; | |
| 220 | } | |
| 221 | ||
| 222 | /** | |
| 223 | * Transport hints as to how the client might communicate with the authenticator this credential | |
| 224 | * is bound to. | |
| 225 | * | |
| 226 | * <p>This SHOULD be set to the value returned by {@link | |
| 227 | * AuthenticatorAttestationResponse#getTransports()} when the credential was created. That value | |
| 228 | * SHOULD NOT be modified. | |
| 229 | * | |
| 230 | * <p>This is only used if the {@link RelyingParty} is configured with a {@link | |
| 231 | * CredentialRepositoryV2}, in which case this is used to set {@link | |
| 232 | * PublicKeyCredentialDescriptor#getTransports()} in {@link | |
| 233 | * PublicKeyCredentialCreationOptions#getExcludeCredentials() excludeCredentials} in {@link | |
| 234 | * RelyingParty#startRegistration(StartRegistrationOptions)} and {@link | |
| 235 | * PublicKeyCredentialRequestOptions#getAllowCredentials() allowCredentials} in {@link | |
| 236 | * RelyingParty#startAssertion(StartAssertionOptions)}. This is not used if the {@link | |
| 237 | * RelyingParty} is configured with a {@link CredentialRepository}. | |
| 238 | * | |
| 239 | * @see <a | |
| 240 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#dom-authenticatorattestationresponse-gettransports">getTransports() | |
| 241 | * in 5.2.1. Information About Public Key Credential (interface | |
| 242 | * AuthenticatorAttestationResponse)</a> | |
| 243 | * @see <a | |
| 244 | * href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#dom-publickeycredentialdescriptor-transports">transports | |
| 245 | * in 5.8.3. Credential Descriptor (dictionary PublicKeyCredentialDescriptor)</a> | |
| 246 | * @see AuthenticatorAttestationResponse#getTransports() | |
| 247 | * @see PublicKeyCredentialDescriptor#getTransports() | |
| 248 | * @deprecated EXPERIMENTAL: This is an experimental feature. It is likely to change or be deleted | |
| 249 | * before reaching a mature release. | |
| 250 | */ | |
| 251 | @Deprecated | |
| 252 | @Override | |
| 253 | public Optional<Set<AuthenticatorTransport>> getTransports() { | |
| 254 |
1
1. getTransports : replaced return value with Optional.empty for com/yubico/webauthn/RegisteredCredential::getTransports → SURVIVED |
return Optional.ofNullable(transports); |
| 255 | } | |
| 256 | ||
| 257 | /** | |
| 258 | * The state of the <a href="https://w3c.github.io/webauthn/#authdata-flags-be">BE flag</a> when | |
| 259 | * this credential was registered, if known. | |
| 260 | * | |
| 261 | * <p>If absent, it is not known whether or not this credential is backup eligible. | |
| 262 | * | |
| 263 | * <p>If present and <code>true</code>, the credential is backup eligible: it can be backed up in | |
| 264 | * some way, most commonly by syncing the private key to a cloud account. | |
| 265 | * | |
| 266 | * <p>If present and <code>false</code>, the credential is not backup eligible: it cannot be | |
| 267 | * backed up in any way. | |
| 268 | * | |
| 269 | * <p>{@link CredentialRepository} implementations SHOULD set this to the first known value | |
| 270 | * returned by {@link RegistrationResult#isBackupEligible()} or {@link | |
| 271 | * AssertionResult#isBackupEligible()}, if known. If unknown, {@link CredentialRepository} | |
| 272 | * implementations SHOULD set this to <code>null</code> or not set this value. | |
| 273 | * | |
| 274 | * @deprecated EXPERIMENTAL: This feature is from a not yet mature standard; it could change as | |
| 275 | * the standard matures. | |
| 276 | */ | |
| 277 | @Deprecated | |
| 278 | @JsonProperty("backupEligible") | |
| 279 | public Optional<Boolean> isBackupEligible() { | |
| 280 |
1
1. isBackupEligible : replaced return value with Optional.empty for com/yubico/webauthn/RegisteredCredential::isBackupEligible → KILLED |
return Optional.ofNullable(backupEligible); |
| 281 | } | |
| 282 | ||
| 283 | /** | |
| 284 | * The last known state of the <a href="https://w3c.github.io/webauthn/#authdata-flags-bs">BS | |
| 285 | * flag</a> for this credential, if known. | |
| 286 | * | |
| 287 | * <p>If absent, the backup state of the credential is not known. | |
| 288 | * | |
| 289 | * <p>If present and <code>true</code>, the credential is believed to be currently backed up. | |
| 290 | * | |
| 291 | * <p>If present and <code>false</code>, the credential is believed to not be currently backed up. | |
| 292 | * | |
| 293 | * <p>{@link CredentialRepository} implementations SHOULD set this to the most recent value | |
| 294 | * returned by {@link AssertionResult#isBackedUp()} or {@link RegistrationResult#isBackedUp()}, if | |
| 295 | * known. If unknown, {@link CredentialRepository} implementations SHOULD set this to <code>null | |
| 296 | * </code> or not set this value. | |
| 297 | * | |
| 298 | * @deprecated EXPERIMENTAL: This feature is from a not yet mature standard; it could change as | |
| 299 | * the standard matures. | |
| 300 | */ | |
| 301 | @Deprecated | |
| 302 | @JsonProperty("backupState") | |
| 303 | public Optional<Boolean> isBackedUp() { | |
| 304 |
1
1. isBackedUp : replaced return value with Optional.empty for com/yubico/webauthn/RegisteredCredential::isBackedUp → KILLED |
return Optional.ofNullable(backupState); |
| 305 | } | |
| 306 | ||
| 307 | public static RegisteredCredentialBuilder.MandatoryStages builder() { | |
| 308 |
1
1. builder : replaced return value with null for com/yubico/webauthn/RegisteredCredential::builder → KILLED |
return new RegisteredCredentialBuilder.MandatoryStages(); |
| 309 | } | |
| 310 | ||
| 311 | public static class RegisteredCredentialBuilder { | |
| 312 | public static class MandatoryStages { | |
| 313 | private final RegisteredCredentialBuilder builder = new RegisteredCredentialBuilder(); | |
| 314 | ||
| 315 | /** | |
| 316 | * {@link RegisteredCredentialBuilder#credentialId(ByteArray) credentialId} is a required | |
| 317 | * parameter. | |
| 318 | * | |
| 319 | * @see RegisteredCredentialBuilder#credentialId(ByteArray) | |
| 320 | */ | |
| 321 | public Step2 credentialId(ByteArray credentialId) { | |
| 322 | builder.credentialId(credentialId); | |
| 323 |
1
1. credentialId : replaced return value with null for com/yubico/webauthn/RegisteredCredential$RegisteredCredentialBuilder$MandatoryStages::credentialId → KILLED |
return new Step2(); |
| 324 | } | |
| 325 | ||
| 326 | public class Step2 { | |
| 327 | /** | |
| 328 | * {@link RegisteredCredentialBuilder#userHandle(ByteArray) userHandle} is a required | |
| 329 | * parameter. | |
| 330 | * | |
| 331 | * @see RegisteredCredentialBuilder#userHandle(ByteArray) | |
| 332 | */ | |
| 333 | public Step3 userHandle(ByteArray userHandle) { | |
| 334 | builder.userHandle(userHandle); | |
| 335 |
1
1. userHandle : replaced return value with null for com/yubico/webauthn/RegisteredCredential$RegisteredCredentialBuilder$MandatoryStages$Step2::userHandle → KILLED |
return new Step3(); |
| 336 | } | |
| 337 | } | |
| 338 | ||
| 339 | public class Step3 { | |
| 340 | /** | |
| 341 | * {@link RegisteredCredentialBuilder#publicKeyCose(ByteArray) publicKeyCose} is a required | |
| 342 | * parameter. | |
| 343 | * | |
| 344 | * <p>The return value of {@link RegistrationResult#getPublicKeyCose()} is a suitable | |
| 345 | * argument for this method. | |
| 346 | * | |
| 347 | * <p>Alternatively, the public key can be specified using the {@link | |
| 348 | * #publicKeyEs256Raw(ByteArray)} method if the key is stored in the U2F format (<code> | |
| 349 | * ALG_KEY_ECC_X962_RAW</code> as specified in <a | |
| 350 | * href="https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-registry-v2.0-id-20180227.html#public-key-representation-formats">FIDO | |
| 351 | * Registry §3.6.2 Public Key Representation Formats</a>). This is mostly useful for public | |
| 352 | * keys registered via the U2F JavaScript API. | |
| 353 | * | |
| 354 | * @see #publicKeyEs256Raw(ByteArray) | |
| 355 | * @see RegisteredCredentialBuilder#publicKeyCose(ByteArray) | |
| 356 | * @see <a | |
| 357 | * href="https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-registry-v2.0-id-20180227.html#public-key-representation-formats">FIDO | |
| 358 | * Registry §3.6.2 Public Key Representation Formats</a> | |
| 359 | */ | |
| 360 | public RegisteredCredentialBuilder publicKeyCose(ByteArray publicKeyCose) { | |
| 361 |
1
1. publicKeyCose : replaced return value with null for com/yubico/webauthn/RegisteredCredential$RegisteredCredentialBuilder$MandatoryStages$Step3::publicKeyCose → KILLED |
return builder.publicKeyCose(publicKeyCose); |
| 362 | } | |
| 363 | ||
| 364 | /** | |
| 365 | * Specify the credential public key in U2F format. | |
| 366 | * | |
| 367 | * <p>An alternative to {@link #publicKeyCose(ByteArray)}, this method expects an {@link | |
| 368 | * COSEAlgorithmIdentifier#ES256 ES256} public key in <code>ALG_KEY_ECC_X962_RAW</code> | |
| 369 | * format as specified in <a | |
| 370 | * href="https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-registry-v2.0-id-20180227.html#public-key-representation-formats">FIDO | |
| 371 | * Registry §3.6.2 Public Key Representation Formats</a>. | |
| 372 | * | |
| 373 | * <p>This is primarily intended for public keys registered via the U2F JavaScript API. If | |
| 374 | * your application has only used the <code>navigator.credentials.create()</code> API to | |
| 375 | * register credentials, you should use {@link #publicKeyCose(ByteArray)} instead. | |
| 376 | * | |
| 377 | * @see RegisteredCredentialBuilder#publicKeyCose(ByteArray) | |
| 378 | */ | |
| 379 | public RegisteredCredentialBuilder publicKeyEs256Raw(ByteArray publicKeyEs256Raw) { | |
| 380 |
1
1. publicKeyEs256Raw : replaced return value with null for com/yubico/webauthn/RegisteredCredential$RegisteredCredentialBuilder$MandatoryStages$Step3::publicKeyEs256Raw → KILLED |
return builder.publicKeyCose(WebAuthnCodecs.rawEcKeyToCose(publicKeyEs256Raw)); |
| 381 | } | |
| 382 | } | |
| 383 | } | |
| 384 | ||
| 385 | /** | |
| 386 | * The credential public key encoded in COSE_Key format, as defined in Section 7 of <a | |
| 387 | * href="https://tools.ietf.org/html/rfc8152">RFC 8152</a>. This method overwrites {@link | |
| 388 | * #publicKeyEs256Raw(ByteArray)}. | |
| 389 | * | |
| 390 | * <p>The return value of {@link RegistrationResult#getPublicKeyCose()} is a suitable argument | |
| 391 | * for this method. | |
| 392 | * | |
| 393 | * <p>This is used to verify the {@link AuthenticatorAssertionResponse#getSignature() signature} | |
| 394 | * in authentication assertions. | |
| 395 | * | |
| 396 | * <p>Alternatively, the public key can be specified using the {@link | |
| 397 | * #publicKeyEs256Raw(ByteArray)} method if the key is stored in the U2F format (<code> | |
| 398 | * ALG_KEY_ECC_X962_RAW</code> as specified in <a | |
| 399 | * href="https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-registry-v2.0-id-20180227.html#public-key-representation-formats">FIDO | |
| 400 | * Registry §3.6.2 Public Key Representation Formats</a>). This is mostly useful for public keys | |
| 401 | * registered via the U2F JavaScript API. | |
| 402 | * | |
| 403 | * @see AttestedCredentialData#getCredentialPublicKey() | |
| 404 | * @see RegistrationResult#getPublicKeyCose() | |
| 405 | */ | |
| 406 |
1
1. publicKeyCose : negated conditional → KILLED |
public RegisteredCredentialBuilder publicKeyCose(@NonNull ByteArray publicKeyCose) { |
| 407 | this.publicKeyCose = publicKeyCose; | |
| 408 |
1
1. publicKeyCose : replaced return value with null for com/yubico/webauthn/RegisteredCredential$RegisteredCredentialBuilder::publicKeyCose → KILLED |
return this; |
| 409 | } | |
| 410 | ||
| 411 | /** | |
| 412 | * Specify the credential public key in U2F format. This method overwrites {@link | |
| 413 | * #publicKeyCose(ByteArray)}. | |
| 414 | * | |
| 415 | * <p>An alternative to {@link #publicKeyCose(ByteArray)}, this method expects an {@link | |
| 416 | * COSEAlgorithmIdentifier#ES256 ES256} public key in <code>ALG_KEY_ECC_X962_RAW</code> format | |
| 417 | * as specified in <a | |
| 418 | * href="https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-registry-v2.0-id-20180227.html#public-key-representation-formats">FIDO | |
| 419 | * Registry §3.6.2 Public Key Representation Formats</a>. | |
| 420 | * | |
| 421 | * <p>This is primarily intended for public keys registered via the U2F JavaScript API. If your | |
| 422 | * application has only used the <code>navigator.credentials.create()</code> API to register | |
| 423 | * credentials, you should use {@link #publicKeyCose(ByteArray)} instead. | |
| 424 | * | |
| 425 | * @see RegisteredCredentialBuilder#publicKeyCose(ByteArray) | |
| 426 | */ | |
| 427 | public RegisteredCredentialBuilder publicKeyEs256Raw(ByteArray publicKeyEs256Raw) { | |
| 428 |
1
1. publicKeyEs256Raw : replaced return value with null for com/yubico/webauthn/RegisteredCredential$RegisteredCredentialBuilder::publicKeyEs256Raw → KILLED |
return publicKeyCose(WebAuthnCodecs.rawEcKeyToCose(publicKeyEs256Raw)); |
| 429 | } | |
| 430 | } | |
| 431 | } | |
Mutations | ||
| 107 |
1.1 |
|
| 206 |
1.1 |
|
| 207 |
1.1 |
|
| 208 |
1.1 |
|
| 254 |
1.1 |
|
| 280 |
1.1 |
|
| 304 |
1.1 |
|
| 308 |
1.1 |
|
| 323 |
1.1 |
|
| 335 |
1.1 |
|
| 361 |
1.1 |
|
| 380 |
1.1 |
|
| 406 |
1.1 |
|
| 408 |
1.1 |
|
| 428 |
1.1 |