Class BaseCryptCodecHandler

    • Method Detail

      • processBytesFully

        public static byte[] processBytesFully​(BufferedBlockCipher cipher,
                                               byte[] inArray)
        Runs the given block cipher over the given bytes into a new byte[]. The cipher carries the direction it was initialized for, so this both encrypts and decrypts.
      • applyPageNumber

        public static byte[] applyPageNumber​(byte[] key,
                                             int offset,
                                             int pageNumber)
        Returns a copy of the given key with the bytes of the given pageNumber applied at the given offset using XOR.
      • hash

        public static byte[] hash​(Digest digest,
                                  byte[] bytes)
        Hashes the given bytes using the given digest and returns the result.
      • hash

        public static byte[] hash​(Digest digest,
                                  byte[] bytes1,
                                  byte[] bytes2)
        Hashes the given bytes1 and bytes2 using the given digest and returns the result.
      • hash

        public static byte[] hash​(Digest digest,
                                  byte[] bytes,
                                  int resultLen)
        Hashes the given bytes using the given digest and returns the hash fixed to the given length.
      • hash

        public static byte[] hash​(Digest digest,
                                  byte[] bytes1,
                                  byte[] bytes2,
                                  int resultLen)
        Hashes the given bytes1 and bytes2 using the given digest and returns the hash fixed to the given length.
      • iterateHash

        public static byte[] iterateHash​(Digest digest,
                                         byte[] baseHash,
                                         int iterations)
        Hashes the given hash with its own iteration number, the given number of times. This is the work a spin count asks for.
      • fixToLength

        public static byte[] fixToLength​(byte[] bytes,
                                         int len)
        Returns:
        a byte array of the given length, truncating or padding the given byte array as necessary.
      • fixToLength

        public static byte[] fixToLength​(byte[] bytes,
                                         int len,
                                         int padByte)
        Returns:
        a byte array of the given length, truncating or padding the given byte array as necessary using the given padByte.
      • wrap

        public static ByteBuffer wrap​(byte[] bytes)
        Returns:
        a new ByteBuffer wrapping the given bytes with the appropriate byte order
      • applyHeaderMask

        public static void applyHeaderMask​(ByteBuffer page,
                                           JetFormat format)
        Removes the header mask from page 0, or puts it back. The mask is xor, so the two are one operation.
      • createEncodingKey

        public static int createEncodingKey()
        Returns a page 0 key of the shape ms access writes. Ms access uses the windows tick count with 0xa0a00000 set, which makes the high bytes track how long the machine had been running. A random value with the same bits set is the same shape without being guessable, and nothing on the read path compares the key against anything but zero.
      • bits2bytes

        public static int bits2bytes​(int bits)
        Returns:
        the number of whole bytes the given number of bits holds
      • fill

        public static byte[] fill​(byte[] bytes,
                                  int value)
        Fills the given array with the given value and returns it.