ANSI X9.31 hash format

With ANSI X9.31, the string that is processed by the RSA algorithm is formatted by the concatenation of a header, padding, the hash value and a trailer, from the most significant bit to the least significant bit, so that the resulting string is the same length as the modulus of the key.

For CCA, the modulus length must be a multiple of 8 bits.
  • The header consists of the value X'6B'.
  • The padding consists of the value X'BB', repeated as many times as required, and ended with X'BA'.
  • The hash value follows the padding.
  • The trailer consists of a hashing mechanism specifier and final byte. The hashing mechanism specifier is defined as one of the following values:
    X'31'
    RIPEMD-160
    X'32'
    RIPEMD-128
    X'33'
    SHA-1
    X'34'
    SHA-256
  • The final byte is X'CC'.