Class TR31KeyBlock


  • public class TR31KeyBlock
    extends java.lang.Object
    A TR-31 KeyBlock is a byte[] structure. This class is provided to allow applications to extract non-key data from a TR-31 KeyBlock. This class cannot be used to create a TR-31 KeyBlock. It is used only to extract and display non-key data from an existing TR-31 KeyBlock. This class never returns the key bytes. All other data in the TR-31 KeyBlock can be obtained using the getter APIs or by calling the toString() method.
    • Constructor Summary

      Constructors 
      Constructor Description
      TR31KeyBlock​(byte[] TR31_KeyBlockBytes)
      Constructor Note that this method has a long path length because multiple native APIs are called to extract the data from the specified TR-31 Key Block.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getKeyAlgorithm()
      Returns the key algorithm field in the ANSI TR-31 KeyBlock as a string.
      java.lang.String getKeyAlgorithmAsString()
      Returns the key algorithm field in the ANSI TR-31 KeyBlock as an expanded string.
      int getKeyBlockLength()
      Returns the contents of the KeyBlock length field in the ANSI TR-31 Key block.
      java.lang.String getKeyBlockVersion()
      Returns the contents of the KeyBlockVersion field in the ANSI TR-31 Key block.
      java.lang.String getKeyExportability()
      Returns the key exportability field in the ANSI TR-31 KeyBlock as a string.
      java.lang.String getKeyExportabilityAsString()
      Returns the key exportability field in the ANSI TR-31 KeyBlock as an expanded string.
      java.lang.String getKeyMode()
      Returns the key mode field in the ANSI TR-31 KeyBlock as a string.
      java.lang.String getKeyModeAsString()
      Returns the key mode field in the ANSI TR-31 KeyBlock as an expanded string.
      java.lang.String getKeyUsage()
      Returns the key usage field in the ANSI TR-31 KeyBlock as a String.
      java.lang.String getKeyUsageAsString()
      Returns the key usage field in the ANSI TR-31 KeyBlock as an expanded String.
      java.lang.String getKeyVersion()
      Returns the key version field in the ANSI TR-31 KeyBlock as a string.
      int getNumOptDataBlocks()
      Returns the count of optional data blocks contained in the ANSI TR-31 KeyBlock.
      TR31OptionalDataBlock[] getOptDataBlocks()
      Returns the contents of the optional data blocks in the ANSI TR-31 Key block.
      java.lang.String toString()
      Returns a formatted string displaying the non-key data contents of the ANSI TR-31 Key block.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • TR31KeyBlock

        public TR31KeyBlock​(byte[] TR31_KeyBlockBytes)
        Constructor Note that this method has a long path length because multiple native APIs are called to extract the data from the specified TR-31 Key Block.
        Parameters:
        TR31_KeyBlockBytes - the ANSI TR-31 Key Block from which non-key information will be queried.
        Throws:
        java.security.InvalidParameterException - if the TR31_KeyBlock is null.
        JCECCARuntimeException - if the TR31_KeyBlock is not a valid ANSI TR-31 Key Block.
    • Method Detail

      • getKeyBlockVersion

        public java.lang.String getKeyBlockVersion()
        Returns the contents of the KeyBlockVersion field in the ANSI TR-31 Key block. This is a one-byte character.
        Returns:
        the contents of the KeyBlockVersion field in the ANSI TR-31 Key Block.
      • getKeyBlockLength

        public int getKeyBlockLength()
        Returns the contents of the KeyBlock length field in the ANSI TR-31 Key block.
        Returns:
        the contents of the KeyBlockLength field in the ANSI TR-31 Key Block.
      • getKeyUsage

        public java.lang.String getKeyUsage()
        Returns the key usage field in the ANSI TR-31 KeyBlock as a String.
        Returns:
        key usage as a String. This wil be one of the following:
        • D0 DataEncryptionKey
        • K0 KeyEcryptingKey
        • other UnrecognizedKeyUsage
      • getKeyUsageAsString

        public java.lang.String getKeyUsageAsString()
        Returns the key usage field in the ANSI TR-31 KeyBlock as an expanded String.
        Returns:
        key usage as a String. This will be one of the following:
        • DataEncryptionKey
        • KeyEcryptingKey
        • UnrecognizedKeyUsage
      • getKeyAlgorithm

        public java.lang.String getKeyAlgorithm()
        Returns the key algorithm field in the ANSI TR-31 KeyBlock as a string.
        Returns:
        the key algorithm as a String. This will be one of the following:
        • D Single-DES
        • T Triple-DES
        • other UnsupportedAlgorithm
      • getKeyAlgorithmAsString

        public java.lang.String getKeyAlgorithmAsString()
        Returns the key algorithm field in the ANSI TR-31 KeyBlock as an expanded string.
        Returns:
        the key algorithm as a String. This will be one of the following:
        • Single-DES
        • Triple-DES
        • UnsupportedAlgorithm
      • getKeyMode

        public java.lang.String getKeyMode()
        Returns the key mode field in the ANSI TR-31 KeyBlock as a string.
        Returns:
        key mode as a String. This will be one of the following:
        • B EncryptDecrypt
        • E Exporter
        • D Importer
        • other UnrecognizedKeyMode
      • getKeyModeAsString

        public java.lang.String getKeyModeAsString()
        Returns the key mode field in the ANSI TR-31 KeyBlock as an expanded string.
        Returns:
        key mode as a String. This will be one of the following:
        • EncryptDecrypt
        • Exporter
        • Importer
        • UnrecognizedKeyMode
      • getKeyVersion

        public java.lang.String getKeyVersion()
        Returns the key version field in the ANSI TR-31 KeyBlock as a string.
        Returns:
        key mode as a String. This will be one of A, B, or C
      • getKeyExportability

        public java.lang.String getKeyExportability()
        Returns the key exportability field in the ANSI TR-31 KeyBlock as a string.
        Returns:
        key exportability. This is a one byte string indicating whether the key can be exported from this system and, if so, it specifies conditions under which export is permitted. This will be one of the following:
        • "N" Not exportable
        • "E" Exportable under trusted key
        • "S" Exportable under any key
      • getKeyExportabilityAsString

        public java.lang.String getKeyExportabilityAsString()
        Returns the key exportability field in the ANSI TR-31 KeyBlock as an expanded string.
        Returns:
        key exportability as a String. This is a one byte string indicating whether the key can be exported from this system and, if so, it specifies conditions under which export is permitted. This will be one of the following:
        • Not exportable
        • Exportable under trusted key
        • Exportable under any key
      • getNumOptDataBlocks

        public int getNumOptDataBlocks()
        Returns the count of optional data blocks contained in the ANSI TR-31 KeyBlock.
        Returns:
        the count of optional data blocks contained in the ANSI TR-31 Key Block.
      • getOptDataBlocks

        public TR31OptionalDataBlock[] getOptDataBlocks()
        Returns the contents of the optional data blocks in the ANSI TR-31 Key block.
        Returns:
        the contents of the optional data blocks in the ANSI TR-31 Key Block in an array of TR31OptionalDataBlock objects. If there are no optional data blocks in the ANSI TR-31 Key Block, an empty array is returned.
      • toString

        public java.lang.String toString()
        Returns a formatted string displaying the non-key data contents of the ANSI TR-31 Key block. Note that this method may have long path length because, if the TR-31 Key Block has optional data blocks and they have not yet been retrieved, then multiple native APIs are are called to extract them from the TR-31 Key Block.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a formatted string displaying the non-key data contents of the ANSI TR-31 Key block.