Class COSEEC2Key
-
Constructor Summary
ConstructorsConstructorDescriptionCOSEEC2Key
(List<? extends CBORPair> pairs) A constructor with key parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addJwkProperties
(Map<String, Object> map) Add JWK properties to the given map.Create aPrivateKey
instance from this COSE key.Create aPublicKey
instance from this COSE key.getCrv()
Get the curve (the value of thecrv
parameter).byte[]
getD()
Get the private key (the value of thed
parameter).byte[]
getX()
Get the x-coordinate (the value of thex
parameter).getY()
Get the y-coordinate (the value of they
parameter).boolean
Get the flag indicating whether this key contains private parameters.Convert thisCOSEEC2Key
instance to anECPrivateKey
instance.Convert thisCOSEEC2Key
instance to anECPublicKey
instance.toPublic()
Convert this COSE key to a public key.Methods inherited from class com.authlete.cose.COSEKey
build, build, copy, fromJwk, getAlg, getBaseIv, getKeyOps, getKid, getKty, getParameters, toJwk
Methods inherited from class com.authlete.cbor.CBORPairList
encode, findByKey, getPairs, parse, prettify, toString
Methods inherited from class com.authlete.cbor.CBORItem
encode, encodeMajorWithNumber, encodeToBase64, encodeToBase64Url, encodeToHex, getComment, prettify, setComment, toString
-
Constructor Details
-
COSEEC2Key
-
-
Method Details
-
isPrivate
-
toPublic
Description copied from class:COSEKey
Convert this COSE key to a public key.When this
COSEKey
instance is a public key, this method returnsthis
object without any modification. Otherwise, this method creates a newCOSEKey
instance representing a public key and returns the new instance.The default implementation of this method throws an exception. Subclasses should override this method.
- Overrides:
toPublic
in classCOSEKey
- Returns:
- A
COSEKey
instance representing a public key. - Throws:
COSEException
-
addJwkProperties
Description copied from class:COSEKey
Add JWK properties to the given map.This method is called from within the
COSEKey.toJwk()
method. Subclasses of theCOSEKey
class should override this method.- Overrides:
addJwkProperties
in classCOSEKey
- Parameters:
map
- A map to which JWK properties should be added.
-
getCrv
Get the curve (the value of thecrv
parameter).The type of the value is an integer (
int
,long
orBigInteger
) or a string (String
).- Returns:
- The curve.
- See Also:
-
getX
public byte[] getX()Get the x-coordinate (the value of thex
parameter).- Returns:
- The x-coordinate.
-
getY
Get the y-coordinate (the value of they
parameter).The type of the value is either a byte array (
byte[]
) or boolean (Boolean
). When the point is compressed, the y-coordinate is represented by using a single bit. See "2.3.3 Elliptic-Curve-Point-to-Octet-String Conversion" and "2.3.4 Octet-String-to-Elliptic-Curve-Point Conversion" in "SEC 1: Elliptic Curve Cryptography" for details.- Returns:
- The y-coordinate.
- See Also:
-
getD
public byte[] getD()Get the private key (the value of thed
parameter).- Returns:
- The private key.
-
toECPrivateKey
Convert thisCOSEEC2Key
instance to anECPrivateKey
instance.- Returns:
- A new
ECPrivateKey
instance. - Throws:
COSEException
-
toECPublicKey
Convert thisCOSEEC2Key
instance to anECPublicKey
instance.- Returns:
- A new
ECPublicKey
instance. - Throws:
COSEException
-
createPrivateKey
Description copied from class:COSEKey
Create aPrivateKey
instance from this COSE key.The default implementation of this method throws an exception. Subclasses should override this method.
- Overrides:
createPrivateKey
in classCOSEKey
- Returns:
- A
PrivateKey
instance. - Throws:
COSEException
- The creation failed.
-
createPublicKey
Description copied from class:COSEKey
Create aPublicKey
instance from this COSE key.The default implementation of this method throws an exception. Subclasses should override this method.
- Overrides:
createPublicKey
in classCOSEKey
- Returns:
- A
PublicKey
instance. - Throws:
COSEException
- The creation failed.
-