pub enum PublicKey {
ES256 {
x: Vec<u8>,
y: Vec<u8>,
},
ES384 {
x: Vec<u8>,
y: Vec<u8>,
},
EdDSA(Vec<u8>),
RS256 {
n: Vec<u8>,
e: Vec<u8>,
},
}Expand description
The public key extracted from a COSE key structure during registration.
Four algorithms are supported:
- ES256 — ECDSA P-256 with SHA-256 (COSE alg
-7). Most common. - ES384 — ECDSA P-384 with SHA-384 (COSE alg
-35). - EdDSA — Ed25519 (COSE alg
-8). Used by newer FIDO2 authenticators. - RS256 — RSA PKCS#1 v1.5 with SHA-256 (COSE alg
-257). Used by older YubiKey 4-series devices and Windows Hello.
Variants§
ES256
P-256 ECDSA public key (COSE alg -7, kty 2).
x and y are the 32-byte affine coordinates of the public point.
To obtain the 65-byte uncompressed point for ring, prepend 0x04:
0x04 || x (32 bytes) || y (32 bytes).
ES384
P-384 ECDSA public key (COSE alg -35, kty 2).
x and y are the 48-byte affine coordinates of the public point.
To obtain the 97-byte uncompressed point for ring, prepend 0x04:
0x04 || x (48 bytes) || y (48 bytes).
EdDSA(Vec<u8>)
Ed25519 EdDSA public key (COSE alg -8, kty 1 OKP).
The inner Vec<u8> is the raw 32-byte Ed25519 public key,
as encoded in COSE OKP key parameter -2 (x).
RS256
RSA PKCS#1 v1.5 SHA-256 public key (COSE alg -257, kty 3).
n is the big-endian modulus (256 bytes for a 2048-bit key).
e is the big-endian public exponent (typically [0x01, 0x00, 0x01]).