Class COSEEC2Key

  • Constructor Details

    • COSEEC2Key

      public COSEEC2Key(List<? extends CBORPair> pairs)
      A constructor with key parameters.
      Parameters:
      pairs - Key parameters.
  • Method Details

    • isPrivate

      public boolean isPrivate()
      Description copied from class: COSEKey
      Get the flag indicating whether this key contains private parameters.

      Subclasses of the COSEKey class are expected to override this method.

      Overrides:
      isPrivate in class COSEKey
      Returns:
      true if this key contains private parameters.
    • toPublic

      public COSEKey toPublic() throws COSEException
      Description copied from class: COSEKey
      Convert this COSE key to a public key.

      When this COSEKey instance is a public key, this method returns this object without any modification. Otherwise, this method creates a new COSEKey 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 class COSEKey
      Returns:
      A COSEKey instance representing a public key.
      Throws:
      COSEException
    • addJwkProperties

      protected void addJwkProperties(Map<String,Object> map)
      Description copied from class: COSEKey
      Add JWK properties to the given map.

      This method is called from within the COSEKey.toJwk() method. Subclasses of the COSEKey class should override this method.

      Overrides:
      addJwkProperties in class COSEKey
      Parameters:
      map - A map to which JWK properties should be added.
    • getCrv

      public Object getCrv()
      Get the curve (the value of the crv parameter).

      The type of the value is an integer (int, long or BigInteger) or a string (String).

      Returns:
      The curve.
      See Also:
    • getX

      public byte[] getX()
      Get the x-coordinate (the value of the x parameter).
      Returns:
      The x-coordinate.
    • getY

      public Object getY()
      Get the y-coordinate (the value of the y 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 the d parameter).
      Returns:
      The private key.
    • toECPrivateKey

      public ECPrivateKey toECPrivateKey() throws COSEException
      Convert this COSEEC2Key instance to an ECPrivateKey instance.
      Returns:
      A new ECPrivateKey instance.
      Throws:
      COSEException
    • toECPublicKey

      public ECPublicKey toECPublicKey() throws COSEException
      Convert this COSEEC2Key instance to an ECPublicKey instance.
      Returns:
      A new ECPublicKey instance.
      Throws:
      COSEException
    • createPrivateKey

      public PrivateKey createPrivateKey() throws COSEException
      Description copied from class: COSEKey
      Create a PrivateKey instance from this COSE key.

      The default implementation of this method throws an exception. Subclasses should override this method.

      Overrides:
      createPrivateKey in class COSEKey
      Returns:
      A PrivateKey instance.
      Throws:
      COSEException - The creation failed.
    • createPublicKey

      public PublicKey createPublicKey() throws COSEException
      Description copied from class: COSEKey
      Create a PublicKey instance from this COSE key.

      The default implementation of this method throws an exception. Subclasses should override this method.

      Overrides:
      createPublicKey in class COSEKey
      Returns:
      A PublicKey instance.
      Throws:
      COSEException - The creation failed.