Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

New features:

* Added JavaDoc to `COSEAlgorithmIdentifier` constants.
* (Experimental) Added a new suite of interfaces, starting with
`CredentialRepositoryV2`. `RelyingParty` can now be configured with a
`CredentialRepositoryV2` instance instead of a `CredentialRepository`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,14 @@ public class RelyingParty {
* <ol>
* <li>{@link com.yubico.webauthn.data.PublicKeyCredentialParameters#ES256 ES256}
* <li>{@link com.yubico.webauthn.data.PublicKeyCredentialParameters#EdDSA EdDSA}
* <li>{@link com.yubico.webauthn.data.PublicKeyCredentialParameters#ES256 ES384}
* <li>{@link com.yubico.webauthn.data.PublicKeyCredentialParameters#ES256 ES512}
* <li>{@link com.yubico.webauthn.data.PublicKeyCredentialParameters#ES384 ES384}
* <li>{@link com.yubico.webauthn.data.PublicKeyCredentialParameters#ES512 ES512}
* <li>{@link com.yubico.webauthn.data.PublicKeyCredentialParameters#RS256 RS256}
* <li>{@link com.yubico.webauthn.data.PublicKeyCredentialParameters#RS384 RS384}
* <li>{@link com.yubico.webauthn.data.PublicKeyCredentialParameters#RS512 RS512}
* </ol>
*
* @since 0.2.0
* @see PublicKeyCredentialCreationOptions#getAttestation()
* @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-attestation">§6.4.
* Attestation</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ public class RelyingPartyV2<C extends CredentialRecord> {
* <ol>
* <li>{@link PublicKeyCredentialParameters#ES256 ES256}
* <li>{@link PublicKeyCredentialParameters#EdDSA EdDSA}
* <li>{@link PublicKeyCredentialParameters#ES256 ES384}
* <li>{@link PublicKeyCredentialParameters#ES256 ES512}
* <li>{@link PublicKeyCredentialParameters#ES384 ES384}
* <li>{@link PublicKeyCredentialParameters#ES512 ES512}
* <li>{@link PublicKeyCredentialParameters#RS256 RS256}
* <li>{@link PublicKeyCredentialParameters#RS384 RS384}
* <li>{@link PublicKeyCredentialParameters#RS512 RS512}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,109 @@
* registered in the IANA COSE Algorithms registry, for instance, -7 for "ES256" and -257 for
* "RS256".
*
* @since 0.3.0
* @see <a
* href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#typedefdef-cosealgorithmidentifier">§5.10.5.
* Cryptographic Algorithm Identifier (typedef COSEAlgorithmIdentifier)</a>
*/
public enum COSEAlgorithmIdentifier {

/**
* The signature scheme Ed25519 as defined in <a href="https://www.rfc-editor.org/rfc/rfc8032">RFC
* 8032</a>.
*
* <p>Note: This COSE identifier does not in general identify the full Ed25519 parameter suite,
* but is specialized to that meaning within the WebAuthn API.
*
* @since 1.4.0
* @see <a href="https://www.iana.org/assignments/cose/cose.xhtml#algorithms">COSE Algorithms
* registry</a>
* @see <a href="https://www.rfc-editor.org/rfc/rfc8032">RFC 8032</a>
* @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-alg-identifier">WebAuthn
* §5.8.5. Cryptographic Algorithm Identifier (typedef <code>COSEAlgorithmIdentifier</code>
* )</a>
*/
EdDSA(-8),

/**
* ECDSA with SHA-256 on the NIST P-256 curve.
*
* <p>Note: This COSE identifier does not in general restrict the curve to P-256, but is
* specialized to that meaning within the WebAuthn API.
*
* @since 0.3.0
* @see <a href="https://www.iana.org/assignments/cose/cose.xhtml#algorithms">COSE Algorithms
* registry</a>
* @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-alg-identifier">WebAuthn
* §5.8.5. Cryptographic Algorithm Identifier (typedef <code>COSEAlgorithmIdentifier</code>
* )</a>
*/
ES256(-7),

/**
* ECDSA with SHA-384 on the NIST P-384 curve.
*
* <p>Note: This COSE identifier does not in general restrict the curve to P-384, but is
* specialized to that meaning within the WebAuthn API.
*
* @since 2.1.0
* @see <a href="https://www.iana.org/assignments/cose/cose.xhtml#algorithms">COSE Algorithms
* registry</a>
* @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-alg-identifier">WebAuthn
* §5.8.5. Cryptographic Algorithm Identifier (typedef <code>COSEAlgorithmIdentifier</code>
* )</a>
*/
ES384(-35),

/**
* ECDSA with SHA-512 on the NIST P-521 curve.
*
* <p>Note: This COSE identifier does not in general restrict the curve to P-521, but is
* specialized to that meaning within the WebAuthn API.
*
* @since 2.1.0
* @see <a href="https://www.iana.org/assignments/cose/cose.xhtml#algorithms">COSE Algorithms
* registry</a>
* @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-alg-identifier">WebAuthn
* §5.8.5. Cryptographic Algorithm Identifier (typedef <code>COSEAlgorithmIdentifier</code>
* )</a>
*/
ES512(-36),

/**
* RSASSA-PKCS1-v1_5 using SHA-256.
*
* @since 0.3.0
* @see <a href="https://www.iana.org/assignments/cose/cose.xhtml#algorithms">COSE Algorithms
* registry</a>
*/
RS256(-257),

/**
* RSASSA-PKCS1-v1_5 using SHA-384.
*
* @since 2.4.0
* @see <a href="https://www.iana.org/assignments/cose/cose.xhtml#algorithms">COSE Algorithms
* registry</a>
*/
RS384(-258),

/**
* RSASSA-PKCS1-v1_5 using SHA-512.
*
* @since 2.4.0
* @see <a href="https://www.iana.org/assignments/cose/cose.xhtml#algorithms">COSE Algorithms
* registry</a>
*/
RS512(-259),

/**
* RSASSA-PKCS1-v1_5 using SHA-1.
*
* @since 1.5.0
* @see <a href="https://www.iana.org/assignments/cose/cose.xhtml#algorithms">COSE Algorithms
* registry</a>
*/
RS1(-65535);

@JsonValue @Getter private final long id;
Expand All @@ -65,6 +156,7 @@ public enum COSEAlgorithmIdentifier {
* COSEAlgorithmIdentifier}
* @return The {@link COSEAlgorithmIdentifier} instance whose {@link #getId() id} equals <code>id
* </code>, if any.
* @since 0.3.0
* @see <a href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#sctn-alg-identifier">§5.8.5.
* Cryptographic Algorithm Identifier (typedef COSEAlgorithmIdentifier)</a>
*/
Expand All @@ -80,6 +172,7 @@ public static Optional<COSEAlgorithmIdentifier> fromId(long id) {
* COSEAlgorithmIdentifier}, if possible. Returns empty if the {@link COSEAlgorithmIdentifier}
* enum has no constant matching the <code>alg</code> value.
* @throws IllegalArgumentException if <code>publicKeyCose</code> is not a well-formed COSE_Key.
* @since 2.1.0
*/
public static Optional<COSEAlgorithmIdentifier> fromPublicKey(@NonNull ByteArray publicKeyCose) {
final CBORObject ALG = CBORObject.FromObject(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
/**
* Used to supply additional parameters when creating a new credential.
*
* @since 0.2.0
* @see <a
* href="https://www.w3.org/TR/2021/REC-webauthn-2-20210408/#dictdef-publickeycredentialparameters">§5.3.
* Parameters for Credential Generation (dictionary PublicKeyCredentialParameters) </a>
Expand All @@ -44,10 +45,16 @@ public class PublicKeyCredentialParameters {
* Specifies the cryptographic signature algorithm with which the newly generated credential will
* be used, and thus also the type of asymmetric key pair to be generated, e.g., RSA or Elliptic
* Curve.
*
* @since 0.2.0
*/
@NonNull private final COSEAlgorithmIdentifier alg;

/** Specifies the type of credential to be created. */
/**
* Specifies the type of credential to be created.
*
* @since 0.2.0
*/
@NonNull @Builder.Default
private final PublicKeyCredentialType type = PublicKeyCredentialType.PUBLIC_KEY;

Expand All @@ -61,55 +68,71 @@ private PublicKeyCredentialParameters(
/**
* Algorithm {@link COSEAlgorithmIdentifier#EdDSA} and type {@link
* PublicKeyCredentialType#PUBLIC_KEY}.
*
* @since 1.4.0
*/
public static final PublicKeyCredentialParameters EdDSA =
builder().alg(COSEAlgorithmIdentifier.EdDSA).build();

/**
* Algorithm {@link COSEAlgorithmIdentifier#ES256} and type {@link
* PublicKeyCredentialType#PUBLIC_KEY}.
*
* @since 0.3.0
*/
public static final PublicKeyCredentialParameters ES256 =
builder().alg(COSEAlgorithmIdentifier.ES256).build();

/**
* Algorithm {@link COSEAlgorithmIdentifier#ES384} and type {@link
* PublicKeyCredentialType#PUBLIC_KEY}.
*
* @since 2.1.0
*/
public static final PublicKeyCredentialParameters ES384 =
builder().alg(COSEAlgorithmIdentifier.ES384).build();

/**
* Algorithm {@link COSEAlgorithmIdentifier#ES512} and type {@link
* PublicKeyCredentialType#PUBLIC_KEY}.
*
* @since 2.1.0
*/
public static final PublicKeyCredentialParameters ES512 =
builder().alg(COSEAlgorithmIdentifier.ES512).build();

/**
* Algorithm {@link COSEAlgorithmIdentifier#RS1} and type {@link
* PublicKeyCredentialType#PUBLIC_KEY}.
*
* @since 1.5.0
*/
public static final PublicKeyCredentialParameters RS1 =
builder().alg(COSEAlgorithmIdentifier.RS1).build();

/**
* Algorithm {@link COSEAlgorithmIdentifier#RS256} and type {@link
* PublicKeyCredentialType#PUBLIC_KEY}.
*
* @since 0.3.0
*/
public static final PublicKeyCredentialParameters RS256 =
builder().alg(COSEAlgorithmIdentifier.RS256).build();

/**
* Algorithm {@link COSEAlgorithmIdentifier#RS384} and type {@link
* PublicKeyCredentialType#PUBLIC_KEY}.
*
* @since 2.4.0
*/
public static final PublicKeyCredentialParameters RS384 =
builder().alg(COSEAlgorithmIdentifier.RS384).build();

/**
* Algorithm {@link COSEAlgorithmIdentifier#RS512} and type {@link
* PublicKeyCredentialType#PUBLIC_KEY}.
*
* @since 2.4.0
*/
public static final PublicKeyCredentialParameters RS512 =
builder().alg(COSEAlgorithmIdentifier.RS512).build();
Expand All @@ -127,6 +150,7 @@ public static class MandatoryStages {
* {@link PublicKeyCredentialParametersBuilder#alg(COSEAlgorithmIdentifier) alg} is a required
* parameter.
*
* @since 0.3.0
* @see PublicKeyCredentialParametersBuilder#alg(COSEAlgorithmIdentifier)
*/
public PublicKeyCredentialParametersBuilder alg(COSEAlgorithmIdentifier alg) {
Expand Down