Class ECDSASignature

java.lang.Object
io.fusionauth.jwt.ec.ECDSASignature

public class ECDSASignature extends Object
Handle encoding and decoding an ECDSA signature.

The DER encoded ECDSA signature structure is as follows:

                                                                          s byte array
                                                                                   |
                                                        Length of s byte array     |
                                                                             |     |
                                                          Integer Tag        |     |
                        Sequence Tag                                |        |     |
                                  |                                 |        |     |
 DER Encoded ECDSA Signature:  | 0x30 | lenZ | 0x02 | len(r) | r | 0x02 | len(s) | s
                                          |      |       |     |
         Length of the remaining byte array      |       |     |
                                                 |       |     |
                                        Integer Tag      |     |
                                                         |     |
                                     Length of r byte array    |
                                                               |
 
Author:
Daniel DeGroff
  • Constructor Summary

    Constructors
    Constructor
    Description
    ECDSASignature(byte[] bytes)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    derDecode(Algorithm algorithm)
    Accept a DER encoded signature and extract the 'r' and the 's' components of the Elliptic signature.
    byte[]
    Accept an ECDSA encoded signature of the 'r' and 's' elliptic components, return these values DER encoded.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ECDSASignature

      public ECDSASignature(byte[] bytes)
  • Method Details

    • derDecode

      public byte[] derDecode(Algorithm algorithm) throws IOException
      Accept a DER encoded signature and extract the 'r' and the 's' components of the Elliptic signature.
      Parameters:
      algorithm - the signature algorithm used
      Returns:
      a byte array containing the 'r' and the 's' elliptic signature components.
      Throws:
      IOException - when $%@! gets real.
    • derEncode

      public byte[] derEncode() throws IOException
      Accept an ECDSA encoded signature of the 'r' and 's' elliptic components, return these values DER encoded.
      Returns:
      a DER encoded sequence containing the 'r' and the 's' elliptic signature components
      Throws:
      IOException - when $%@! gets real.