Overview
GordianKnot can be personalised to ensure differing securitySpaces. The personalisation is achieved via a SecurityPhrase which is processed
via a set of digests to produce two 512-bit arrays (I and IV) which are then utilised in the various algorithms.
I is often split into 16 integers written as I1 through I16. Similarly
IV is often split into 4 128-bit arrays written as IV1 through IV4
Sample
/* Access factory using security phrase */
final char[] mySecurityPhrase = ...
final GordianFactory myBaseFactory = GordianGenerator.createFactory(mySecurityPhrase);
Generation
The personalisation algorithm is as follows.
- Initialise I and IV to all zeroes
- Create an array of all available digests that have an output length of 512-bits.
- Initialise all digests with a constant value followed by the security phrase
- Finish all digests, creating an array R of the hashResults and xor each of
these hashes into I
- Loop for 2K iterations.
- Update each digest with ALL the elements of R
- Finish each digest, updating its hash in R and xor-ing into I
- Repeat above loop for 2K iterations, xor-ing results into IV instead of I.
- Update each digest with ALL the elements of R
- Finish each digest, updating its hash in R and xor-ing into I
Seeded Random
Several algorithms in GordianKnot require selection of various algorithms in a deterministic fashion based
on a 4-byte seed S. This is performed by creating a 6-byte seed from the combination of the 4-byte seed and
one of the In values, specific to the algorithm. This 6-byte seed in used to instantiate an instance of
the deterministic Random class and algorithm selection is performed via this seeded Random instance.
Key Derivation
The key derivation algorithm that generates a key KA for an algorithm A
from a secret S and vector V is as follows.
- Obtain a seed X from the first 4 bytes of V and obtain a seeded random R using
X and I1
- Obtain a set of two distinct HMACs HM and HA from the seededRandom R
- Initialise both HMac with a key of secret S
- Repeat the following loop until sufficient bits have been generated. Start with C = 0
- Initialise result to all zeros
- Update both Macs with I and IV
- Update both Macs with A, keyLength and C
- Set input DM and DA to V
- Loop for 16 iterations.
- Update HA with DA
- Calculate DA as the hash result of HA
- Update HM with DM and with DA
- Calculate DM as the hash result of HM
- Xor DM into the result
- Increment C and repeat if necessary.