Package org.jmrtd

Class PACEKeySpec

  • All Implemented Interfaces:
    java.io.Serializable, java.security.spec.KeySpec, AccessKeySpec

    public class PACEKeySpec
    extends java.lang.Object
    implements AccessKeySpec
    A key for PACE, can be CAN, MRZ, PIN, or PUK.
    Version:
    $Revision: 1816 $ (Contributions by g.giorkhelidze.)
    Author:
    The JMRTD team ([email protected])
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      PACEKeySpec​(byte[] key, byte keyReference)
      Constructs a key.
      PACEKeySpec​(java.lang.String key, byte keyReference)
      Constructs a PACE key from a string value.
    • Constructor Detail

      • PACEKeySpec

        public PACEKeySpec​(java.lang.String key,
                           byte keyReference)
        Constructs a PACE key from a string value.
        Parameters:
        key - the string value containing CAN, PIN or PUK
        keyReference - indicates the type of key, valid values are MRZ_PACE_KEY_REFERENCE, CAN_PACE_KEY_REFERENCE, PIN_PACE_KEY_REFERENCE, PUK_PACE_KEY_REFERENCE
      • PACEKeySpec

        public PACEKeySpec​(byte[] key,
                           byte keyReference)
        Constructs a key.
        Parameters:
        key - CAN, MRZ, PIN, PUK password bytes
        keyReference - indicates the type of key, valid values are MRZ_PACE_KEY_REFERENCE, CAN_PACE_KEY_REFERENCE, PIN_PACE_KEY_REFERENCE, PUK_PACE_KEY_REFERENCE
    • Method Detail

      • createMRZKey

        public static PACEKeySpec createMRZKey​(BACKeySpec mrz)
                                        throws java.security.GeneralSecurityException
        Creates a PACE key from relevant details from a Machine Readable Zone.
        Parameters:
        mrz - the details from the Machine Readable Zone
        Returns:
        the PACE key
        Throws:
        java.security.GeneralSecurityException - on error
      • createCANKey

        public static PACEKeySpec createCANKey​(java.lang.String can)
        Creates a PACE key from a Card Access Number.
        Parameters:
        can - the Card Access Number
        Returns:
        the PACE key
      • createPINKey

        public static PACEKeySpec createPINKey​(java.lang.String pin)
        Creates a PACE key from a PIN.
        Parameters:
        pin - the PIN
        Returns:
        the PACE key
      • createPUKKey

        public static PACEKeySpec createPUKKey​(java.lang.String puk)
        Creates a PACE key from a PUK.
        Parameters:
        puk - the PUK
        Returns:
        the PACE key
      • getAlgorithm

        public java.lang.String getAlgorithm()
        Returns the algorithm.
        Specified by:
        getAlgorithm in interface AccessKeySpec
        Returns:
        the algorithm
      • getKeyReference

        public byte getKeyReference()
        Returns the type of key, valid values are MRZ_PACE_KEY_REFERENCE, CAN_PACE_KEY_REFERENCE, PIN_PACE_KEY_REFERENCE, PUK_PACE_KEY_REFERENCE.
        Returns:
        the type of key
      • getKey

        public byte[] getKey()
        Returns the key bytes.
        Specified by:
        getKey in interface AccessKeySpec
        Returns:
        the key bytes
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object