Class COSEKeyBuilder
java.lang.Object
com.authlete.cose.COSEKeyBuilder
- Since:
- 1.1
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionalg
(int alg) Set the "alg (3)" parameter.Set the "alg (3)" parameter.baseIv
(byte[] baseIv) Set the "Base IV (5)" parameter.baseIvInBase64Url
(String baseIv) Set the "Base IV (5)" parameter.build()
Build an instance ofCOSEKey
or its subclass when possible (e.g.Build aCOSEEC2Key
instance.Build aCOSEOKPKey
instance.ec2Crv
(int crv) Set the "crv (-1)" parameter for the key type "EC2".Set the "crv (-1)" parameter for the key type "EC2".Set "P-256 (1)" to the "crv (-1)" parameter for the key type "EC2".Set "P-384 (2)" to the "crv (-1)" parameter for the key type "EC2".Set "P-521 (3)" to the "crv (-1)" parameter for the key type "EC2".Set "secp256k1 (8)" to the "crv (-1)" parameter for the key type "EC2".ec2D
(byte[] d) Set the "d (-4)" parameter for the key type "EC2".Set the "d (-4)" parameter for the key type "EC2".ec2X
(byte[] x) Set the "x (-2)" parameter for the key type "EC2".Set the "x (-2)" parameter for the key type "EC2".ec2Y
(boolean y) Set the "y (-3)" parameter for the key type "EC2".ec2Y
(byte[] y) Set the "y (-3)" parameter for the key type "EC2".Set the "y (-3)" parameter for the key type "EC2".hssLmsPub
(byte[] pub) Set the "pub (-1)" parameter for the key type "HSS-LMS".Set the "pub (-1)" parameter for the key type "HSS-LMS".Set the "key_ops (4)" parameter.kid
(byte[] kid) Set the "kid (2)" parameter.Set the "kid (2)" parameter.kty
(int kty) Set the "kty (1)" parameter.Set the "kty (1)" parameter.ktyEC2()
Set "EC2 (2)" to the "kty (1)" parameter.Set "HSS-LMS (5)" to the "kty (1)" parameter.ktyOKP()
Set "OKP (1)" to the "kty (1)" parameter.ktyRSA()
Set "RSA (3)" to the "kty (1)" parameter.Set "Symmetric (4)" to the "kty (1)" parameter.Set "WalnutDSA (6)" to the "kty (1)" parameter.okpCrv
(int crv) Set the "crv (-1)" parameter for the key type "OKP".Set the "crv (-1)" parameter for the key type "OKP".Set "Ed25519 (6)" to the "crv (-1)" parameter for the key type "OKP".Set "Ed448 (7)" to the "crv (-1)" parameter for the key type "OKP".Set "X25519 (4)" to the "crv (-1)" parameter for the key type "OKP".Set "X448 (5)" to the "crv (-1)" parameter for the key type "OKP".okpD
(byte[] d) Set the "d (-4)" parameter for the key type "OKP".Set the "d (-4)" parameter for the key type "OKP".okpX
(byte[] x) Set the "x (-2)" parameter for the key type "OKP".Set the "x (-2)" parameter for the key type "OKP".Set a parameter.rsaD
(byte[] d) Set the "d (-3)" parameter for the key type "RSA".rsaDI
(byte[] d_i) Set the "d_i (-11)" parameter for the key type "RSA".rsaDIInBase64Url
(String d_i) Set the "d_i (-11)" parameter for the key type "RSA".Set the "d (-3)" parameter for the key type "RSA".rsaDP
(byte[] dP) Set the "dP (-6)" parameter for the key type "RSA".Set the "dP (-6)" parameter for the key type "RSA".rsaDQ
(byte[] dQ) Set the "dQ (-7)" parameter for the key type "RSA".Set the "dQ (-7)" parameter for the key type "RSA".rsaE
(byte[] e) Set the "e (-2)" parameter for the key type "RSA".Set the "e (-2)" parameter for the key type "RSA".rsaN
(byte[] n) Set the "n (-1)" parameter for the key type "RSA".Set the "n (-1)" parameter for the key type "RSA".Set the "other (-9)" parameter for the key type "RSA".rsaP
(byte[] p) Set the "p (-4)" parameter for the key type "RSA".Set the "p (-4)" parameter for the key type "RSA".rsaQ
(byte[] q) Set the "q (-5)" parameter for the key type "RSA".Set the "q (-5)" parameter for the key type "RSA".rsaQInv
(byte[] qInv) Set the "qInv (-8)" parameter for the key type "RSA".rsaQInvInBase64Url
(String qInv) Set the "qInv (-8)" parameter for the key type "RSA".rsaRI
(byte[] r_i) Set the "r_i (-10)" parameter for the key type "RSA".rsaRIInBase64Url
(String r_i) Set the "r_i (-10)" parameter for the key type "RSA".rsaTI
(byte[] t_i) Set the "t_i (-12)" parameter for the key type "RSA".rsaTIInBase64Url
(String t_i) Set the "t_i (-12)" parameter for the key type "RSA".symmetricK
(byte[] k) Set the "k (-1)" parameter for the key type "Symmetric".Set the "k (-1)" parameter for the key type "Symmetric".walnutDsaMatrix1
(List<List<Number>> matrix1) Set the "matrix 1 (-4)" parameter for the key type "WalnutDSA".walnutDsaMatrix2
(List<List<Number>> matrix2) Set the "matrix 2 (-6)" parameter for the key type "WalnutDSA".walnutDsaN
(Number N) Set the "N (-1)" parameter for the key type "WalnutDSA".walnutDsaPermutation1
(List<Number> permutation1) Set the "permutation 1 (-5)" parameter for the key type "WalnutDSA".walnutDsaQ
(Number q) Set the "q (-2)" parameter for the key type "WalnutDSA".walnutDsaTValues
(List<Number> tValues) Set the "t-values (-3)" parameter for the key type "WalnutDSA".
-
Constructor Details
-
COSEKeyBuilder
public COSEKeyBuilder()
-
-
Method Details
-
put
Set a parameter.- Parameters:
key
- The key of the parameter.value
- The value of the parameter.- Returns:
this
object.
-
kty
Set the "kty (1)" parameter.- Parameters:
kty
- The key type.- Returns:
this
object.- See Also:
-
kty
Set the "kty (1)" parameter.- Parameters:
kty
- The key type.- Returns:
this
object.- See Also:
-
ktyOKP
-
ktyEC2
-
ktyRSA
-
ktySymmetric
Set "Symmetric (4)" to the "kty (1)" parameter.- Returns:
this
object.
-
ktyHSSLMS
Set "HSS-LMS (5)" to the "kty (1)" parameter.- Returns:
this
object.
-
ktyWalnutDSA
Set "WalnutDSA (6)" to the "kty (1)" parameter.- Returns:
this
object.
-
kid
Set the "kid (2)" parameter.- Parameters:
kid
- The key ID.- Returns:
this
object.
-
kid
Set the "kid (2)" parameter.- Parameters:
kid
- The key ID. Its UTF-8 byte sequence is used.- Returns:
this
object.
-
alg
Set the "alg (3)" parameter.- Parameters:
alg
- The algorithm.- Returns:
this
object.- See Also:
-
alg
Set the "alg (3)" parameter.- Parameters:
alg
- The algorithm.- Returns:
this
object.- See Also:
-
keyOps
Set the "key_ops (4)" parameter.- Parameters:
operations
- Key operations.- Returns:
this
object.
-
baseIv
Set the "Base IV (5)" parameter.- Parameters:
baseIv
- The base IV.- Returns:
this
object.
-
baseIvInBase64Url
Set the "Base IV (5)" parameter.- Parameters:
baseIv
- The base IV, expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
okpCrv
Set the "crv (-1)" parameter for the key type "OKP".- Parameters:
crv
- The curve.- Returns:
this
object.
-
okpCrv
Set the "crv (-1)" parameter for the key type "OKP".- Parameters:
crv
- The curve.- Returns:
this
object.
-
okpCrvX25519
Set "X25519 (4)" to the "crv (-1)" parameter for the key type "OKP".- Returns:
this
object.
-
okpCrvX448
Set "X448 (5)" to the "crv (-1)" parameter for the key type "OKP".- Returns:
this
object.
-
okpCrvEd25519
Set "Ed25519 (6)" to the "crv (-1)" parameter for the key type "OKP".- Returns:
this
object.
-
okpCrvEd448
Set "Ed448 (7)" to the "crv (-1)" parameter for the key type "OKP".- Returns:
this
object.
-
okpX
Set the "x (-2)" parameter for the key type "OKP".- Parameters:
x
- The public key.- Returns:
this
object.
-
okpXInBase64Url
Set the "x (-2)" parameter for the key type "OKP".- Parameters:
x
- The public key, expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
okpD
Set the "d (-4)" parameter for the key type "OKP".- Parameters:
d
- The private key.- Returns:
this
object.
-
okpDInBase64Url
Set the "d (-4)" parameter for the key type "OKP".- Parameters:
d
- The private key, expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
ec2Crv
Set the "crv (-1)" parameter for the key type "EC2".- Parameters:
crv
- The curve.- Returns:
this
object.
-
ec2Crv
Set the "crv (-1)" parameter for the key type "EC2".- Parameters:
crv
- The curve.- Returns:
this
object.
-
ec2CrvP256
Set "P-256 (1)" to the "crv (-1)" parameter for the key type "EC2".- Returns:
this
object.
-
ec2CrvP384
Set "P-384 (2)" to the "crv (-1)" parameter for the key type "EC2".- Returns:
this
object.
-
ec2CrvP521
Set "P-521 (3)" to the "crv (-1)" parameter for the key type "EC2".- Returns:
this
object.
-
ec2CrvSecp256k1
Set "secp256k1 (8)" to the "crv (-1)" parameter for the key type "EC2".- Returns:
this
object.
-
ec2X
Set the "x (-2)" parameter for the key type "EC2".- Parameters:
x
- The x-coordinate.- Returns:
this
object.
-
ec2XInBase64Url
Set the "x (-2)" parameter for the key type "EC2".- Parameters:
x
- The x-coordinate, expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
ec2Y
Set the "y (-3)" parameter for the key type "EC2".- Parameters:
y
- The y-coordinate.- Returns:
this
object.
-
ec2YInBase64Url
Set the "y (-3)" parameter for the key type "EC2".- Parameters:
y
- The y-coordinate, expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
ec2Y
Set the "y (-3)" parameter for the key type "EC2".- Parameters:
y
- The y-coordinate.- Returns:
this
object.
-
ec2D
Set the "d (-4)" parameter for the key type "EC2".- Parameters:
d
- The private key.- Returns:
this
object.
-
ec2DInBase64Url
Set the "d (-4)" parameter for the key type "EC2".- Parameters:
d
- The private key, expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
rsaN
Set the "n (-1)" parameter for the key type "RSA".- Parameters:
n
- The RSA modulus n.- Returns:
this
object.
-
rsaNInBase64Url
Set the "n (-1)" parameter for the key type "RSA".- Parameters:
n
- The RSA modulus n, expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
rsaE
Set the "e (-2)" parameter for the key type "RSA".- Parameters:
e
- The RSA public exponent e.- Returns:
this
object.
-
rsaEInBase64Url
Set the "e (-2)" parameter for the key type "RSA".- Parameters:
e
- The RSA public exponent e, expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
rsaD
Set the "d (-3)" parameter for the key type "RSA".- Parameters:
d
- The RSA private exponent d.- Returns:
this
object.
-
rsaDInBase64Url
Set the "d (-3)" parameter for the key type "RSA".- Parameters:
d
- The RSA private exponent d, expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
rsaP
Set the "p (-4)" parameter for the key type "RSA".- Parameters:
p
- The prime factor p of n.- Returns:
this
object.
-
rsaPInBase64Url
Set the "p (-4)" parameter for the key type "RSA".- Parameters:
p
- The prime factor p of n, expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
rsaQ
Set the "q (-5)" parameter for the key type "RSA".- Parameters:
q
- The prime factor q of n.- Returns:
this
object.
-
rsaQInBase64url
Set the "q (-5)" parameter for the key type "RSA".- Parameters:
q
- The prime factor q of n, expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
rsaDP
Set the "dP (-6)" parameter for the key type "RSA".- Parameters:
dP
- d mod (p -1)- Returns:
this
object.
-
rsaDPInBase64Url
Set the "dP (-6)" parameter for the key type "RSA".- Parameters:
dP
- d mod (p -1), expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
rsaDQ
Set the "dQ (-7)" parameter for the key type "RSA".- Parameters:
dQ
- d mod (q -1)- Returns:
this
object.
-
rsaDQInBase64Url
Set the "dQ (-7)" parameter for the key type "RSA".- Parameters:
dQ
- d mod (q -1), expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
rsaQInv
Set the "qInv (-8)" parameter for the key type "RSA".- Parameters:
qInv
- The CRT coefficient q^(-1) mod p.- Returns:
this
object.
-
rsaQInvInBase64Url
Set the "qInv (-8)" parameter for the key type "RSA".- Parameters:
qInv
- The CRT coefficient q^(-1) mod p, expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
rsaOther
Set the "other (-9)" parameter for the key type "RSA".- Parameters:
other
- Other prime infos, an array.- Returns:
this
object.
-
rsaRI
Set the "r_i (-10)" parameter for the key type "RSA".- Parameters:
r_i
- A prime factor r_i of n, where i >= 3.- Returns:
this
object.
-
rsaRIInBase64Url
Set the "r_i (-10)" parameter for the key type "RSA".- Parameters:
r_i
- A prime factor r_i of n, where i >= 3. Expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
rsaDI
Set the "d_i (-11)" parameter for the key type "RSA".- Parameters:
d_i
- d mod (r_i - 1).- Returns:
this
object.
-
rsaDIInBase64Url
Set the "d_i (-11)" parameter for the key type "RSA".- Parameters:
d_i
- d mod (r_i - 1). Expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
rsaTI
Set the "t_i (-12)" parameter for the key type "RSA".- Parameters:
t_i
- The CRT coefficient t_i = (r_1 * r_2 * ... * r_(i-1))^(-1) mod r_i.- Returns:
this
object.
-
rsaTIInBase64Url
Set the "t_i (-12)" parameter for the key type "RSA".- Parameters:
t_i
- The CRT coefficient t_i = (r_1 * r_2 * ... * r_(i-1))^(-1) mod r_i. Expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
symmetricK
Set the "k (-1)" parameter for the key type "Symmetric".- Parameters:
k
- The key value.- Returns:
this
object.
-
symmetricKInBase64Url
Set the "k (-1)" parameter for the key type "Symmetric".- Parameters:
k
- The key value, expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
hssLmsPub
Set the "pub (-1)" parameter for the key type "HSS-LMS".- Parameters:
pub
- The public key.- Returns:
this
object.
-
hssLmsPubInBase64Url
Set the "pub (-1)" parameter for the key type "HSS-LMS".- Parameters:
pub
- The public key, expressed in the base64url format.- Returns:
this
object.- Since:
- 1.5
-
walnutDsaN
Set the "N (-1)" parameter for the key type "WalnutDSA".- Parameters:
N
- Group and Matrix (NxN) size.- Returns:
this
object.
-
walnutDsaQ
Set the "q (-2)" parameter for the key type "WalnutDSA".- Parameters:
q
- Finite field F_q.- Returns:
this
object.
-
walnutDsaTValues
Set the "t-values (-3)" parameter for the key type "WalnutDSA".- Parameters:
tValues
- List of T-values, entries in F_q.- Returns:
this
object.
-
walnutDsaMatrix1
Set the "matrix 1 (-4)" parameter for the key type "WalnutDSA".- Parameters:
matrix1
- NxN Matrix of entries in F_q in column-major form.- Returns:
this
object.
-
walnutDsaPermutation1
Set the "permutation 1 (-5)" parameter for the key type "WalnutDSA".- Parameters:
permutation1
- Permutation associated with matrix 1.- Returns:
this
object.
-
walnutDsaMatrix2
Set the "matrix 2 (-6)" parameter for the key type "WalnutDSA".- Parameters:
matrix2
- NxN Matrix of entries in F_q in column-major form.- Returns:
this
object.
-
buildOKPKey
-
buildEC2Key
-
build
- Returns:
this
object.- Throws:
COSEException
-