GordianKnot provide three kinds of locks that are password protected.
A keySetLock can be either be used to secure an existing keySet, or it can be used to create a new random keySet.
/* Access factory */ final GordianFactory myBaseFactory = GordianGenerator.createFactory(); final GordianLockFactory myLockFactory = myBaseFactory.getLockFactory(); /* Create a lock for a new keySet */ final GordianPasswordLockSpec mySpec = new GordianPasswordLockSpec(new GordianKeySetSpec(GordianLength.LEN_256)); final char[] myPassword = ... final GordianKeySetLock myLock = myLockFactory.newKeySetLock(mySpec, myPassword); final GordianKeySet myKeySet = myLock.getKeySet(); final byte[] myLockBytes = myLock.getLockBytes(); /* Resolve the lock */ final GordianKeySetLock myResolved = myLockFactory.resolveKeySetLock(myLockBytes, myPassword);
A keySetLock can either be used to secure an existing factory, or it can be used to create a new random factory.
/* Access factory */ final GordianFactory myBaseFactory = GordianGenerator.createFactory(); final GordianLockFactory myLockFactory = myBaseFactory.getLockFactory(); /* Create a lock for a new factory */ final GordianPasswordLockSpec mySpec = new GordianPasswordLockSpec(new GordianKeySetSpec(GordianLength.LEN_256)); final char[] myPassword = ... final GordianFactoryLock myLock = myLockFactory.newFactoryLock(mySpec, myPassword); final GordianFactory myFactory = myLock.getFactory(); final GordianKeySet myKeySet = myFactory.getEmbeddedKeySet(); final byte[] myLockBytes = myLock.getLockBytes(); /* Resolve the lock */ final GordianFactpryLock myResolved = myLockFactory.resolveFactoryLock(myLockBytes, myPassword);
A keyPairLock can be used to create a new secured random keySet using an agreement-capable keypair.
/* Access factory */ final GordianFactory myBaseFactory = GordianGenerator.createFactory(); final GordianLockFactory myLockFactory = myBaseFactory.getLockFactory(); final GordianKeyPairFactory myKeyPairFactory = myBase.getKeyPairFactory(); final GordianAgreementFactory myAgreementFactory = myKeyPairFactory.getAgreementFactory(); /* Access keyPairGenerator and create sending/receiving pairs */ final GordianKeyPairSpec mySpec = GordianKeyPairSpec.dh(GordianDHGroup.FFDHE2048); final GordianKeyPairGenerator myGenerator = myKeyPairFactory.getKeyPairGenerator(mySpec); final GordianKeyPair myKeyPair = myGenerator.generateKeyPair(); /* Create a lock for a new keySet */ final GordianPasswordLockSpec mySpec = new GordianPasswordLockSpec(new GordianKeySetSpec(GordianLength.LEN_256)); final char[] myPassword = ... final GordianKeyPairLock myLock = myLockFactory.newKeyPairLock(mySpec, myKeyPair, myPassword); final GordianKeySet myKeySet = myLock.getKeySet(); final byte[] myLockBytes = myLock.getLockBytes(); /* Resolve the lock */ final GordianKeyPairLock myResolved = myLockFactory.resolveKeyPairLock(myLockBytes, myKeyPair, myPassword);