CPD Results
The following document contains the results of PMD's CPD 7.12.0.
Duplications
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianBlake2Tree.java | 580 |
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianSkeinTree.java | 649 |
theDigest.doFinal(theResult, 0); myLevel.setElementAt(Arrays.clone(theResult), myParentIndex); return myParentIndex; } } /** * Simple Vector class. * <p>This is a cut down version of the java Vector class to avoid use of synchronised. */ private static class SimpleVector { /** * The initial capacity. */ private static final int INITCAPACITY = 8; /** * The array buffer holding elements. */ private Object[] elementData; /** * The number of valid components in this {@code SimpleVector} object. */ private int elementCount; /** * Constructor. */ SimpleVector() { elementData = new Object[INITCAPACITY]; } /** * Returns the number of components in this vector. * @return the vector size */ int size() { return elementCount; } /** * Tests if this vector has no components. * @return true/false */ boolean isEmpty() { return elementCount == 0; } /** * Returns the first component of the vector. * @return the first component of the vector * @throws NoSuchElementException if this vector is empty */ Object firstElement() { if (elementCount == 0) { throw new NoSuchElementException(); } return elementData[0]; } /** * Returns the last component of the vector. * @return the last component of the vector, i.e., the component at index * <code>size() - 1</code>. * @throws NoSuchElementException if this vector is empty */ Object lastElement() { if (elementCount == 0) { throw new NoSuchElementException(); } return elementData[elementCount - 1]; } /** * Returns the component at the specified index. * * @param index an index into this vector * @return the component at the specified index * @throws ArrayIndexOutOfBoundsException if the index is out of range * ({@code index < 0 || index >= size()}) */ Object elementAt(final int index) { if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); } return elementData[index]; } /** * Sets the component at the specified {@code index} of this * vector to be the specified object. The previous component at that * position is discarded. * * <p>The index must be a value greater than or equal to {@code 0} * and less than the current size of the vector. * * @param obj what the component is to be set to * @param index the specified index * @throws ArrayIndexOutOfBoundsException if the index is out of range * ({@code index < 0 || index >= size()}) */ void setElementAt(final Object obj, final int index) { if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); } elementData[index] = obj; } /** * Adds the specified component to the end of this vector, * increasing its size by one. The capacity of this vector is * increased if its size becomes greater than its capacity. * * @param obj the component to be added */ void addElement(final Object obj) { if (elementCount == elementData.length) { final Object[] newData = new Object[elementData.length << 1]; System.arraycopy(elementData, 0, newData, 0, elementCount); elementData = newData; } elementData[elementCount++] = obj; } /** * Removes all of the elements from this Vector. The Vector will * be empty after this call returns (unless it throws an exception). */ void clear() { for (int i = 0; i < elementCount; i++) { elementData[i] = null; } elementCount = 0; } /** * Returns an enumeration of the components of this vector. * @return the enumeration */ Enumeration elements() { return new Enumeration() { private int count; public boolean hasMoreElements() { return count < elementCount; } public Object nextElement() { if (count < elementCount) { return elementData[count++]; } throw new NoSuchElementException("Vector Enumeration"); } }; } } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\jca\JcaEncryptor.java | 68 |
net\sourceforge\joceanus\gordianknot\impl\jca\JcaEncryptor.java | 232 |
JcaBlockEncryptor(final JcaFactory pFactory, final GordianEncryptorSpec pSpec) throws GordianException { /* Initialise underlying cipher */ super(pFactory, pSpec); theEncryptor = JcaEncryptorFactory.getJavaEncryptor(getAlgorithmName(pSpec), false); } @Override protected JcaPublicKey getPublicKey() { return (JcaPublicKey) super.getPublicKey(); } @Override protected JcaPrivateKey getPrivateKey() { return (JcaPrivateKey) super.getPrivateKey(); } @Override public void initForEncrypt(final GordianKeyPair pKeyPair) throws GordianException { try { /* Initialise underlying cipher */ JcaKeyPair.checkKeyPair(pKeyPair); super.initForEncrypt(pKeyPair); /* Initialise for encryption */ theEncryptor.init(Cipher.ENCRYPT_MODE, getPublicKey().getPublicKey(), getRandom()); } catch (InvalidKeyException e) { throw new GordianCryptoException(ERROR_INIT, e); } } @Override public void initForDecrypt(final GordianKeyPair pKeyPair) throws GordianException { try { /* Initialise underlying cipher */ JcaKeyPair.checkKeyPair(pKeyPair); super.initForDecrypt(pKeyPair); /* Initialise for decryption */ theEncryptor.init(Cipher.DECRYPT_MODE, getPrivateKey().getPrivateKey()); } catch (InvalidKeyException e) { throw new GordianCryptoException(ERROR_INIT, e); } } @Override public byte[] encrypt(final byte[] pBytes) throws GordianException { /* Check that we are in encryption mode */ checkMode(GordianEncryptMode.ENCRYPT); /* Encrypt the message */ return processData(pBytes); } @Override public byte[] decrypt(final byte[] pBytes) throws GordianException { /* Check that we are in decryption mode */ checkMode(GordianEncryptMode.DECRYPT); /* Decrypt the message */ return processData(pBytes); } /** * Process a data buffer. * @param pData the buffer to process * @return the processed buffer * @throws GordianException on error */ private byte[] processData(final byte[] pData) throws GordianException { try { |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyDHKeyPair.java | 474 |
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyEllipticKeyPair.java | 650 |
theAgreement = new DHBasicAgreement(); enableDerivation(); } @Override public GordianAgreementMessageASN1 acceptClientHelloASN1(final GordianKeyPair pServer, final GordianAgreementMessageASN1 pClientHello) throws GordianException { /* Process clientHello */ BouncyKeyPair.checkKeyPair(pServer); processClientHelloASN1(pClientHello); final BouncyPrivateKey<?> myPrivate = (BouncyPrivateKey<?>) getPrivateKey(getServerEphemeralKeyPair()); final BouncyPublicKey<?> myPublic = (BouncyPublicKey<?>) getPublicKey(getClientEphemeralKeyPair()); /* Derive the secret */ theAgreement.init(myPrivate.getPrivateKey()); final BigInteger mySecretInt = theAgreement.calculateAgreement(myPublic.getPublicKey()); final byte[] mySecret = BigIntegers.asUnsignedByteArray(theAgreement.getFieldSize(), mySecretInt); /* Store secret */ storeSecret(mySecret); /* Return the serverHello */ return buildServerHelloASN1(pServer); } @Override public void acceptServerHelloASN1(final GordianKeyPair pServer, final GordianAgreementMessageASN1 pServerHello) throws GordianException { /* process the serverHello */ BouncyKeyPair.checkKeyPair(pServer); processServerHelloASN1(pServer, pServerHello); final BouncyPrivateKey<?> myPrivate = (BouncyPrivateKey<?>) getPrivateKey(getClientEphemeralKeyPair()); /* Calculate agreement */ theAgreement.init(myPrivate.getPrivateKey()); final BouncyPublicKey<?> myPublic = (BouncyPublicKey<?>) getPublicKey(getServerEphemeralKeyPair()); final BigInteger mySecretInt = theAgreement.calculateAgreement(myPublic.getPublicKey()); final byte[] mySecret = BigIntegers.asUnsignedByteArray(theAgreement.getFieldSize(), mySecretInt); /* Store secret */ storeSecret(mySecret); } } /** * DH Unified Agreement. */ public static class BouncyDHUnifiedAgreement |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyDSTUKeyPair.java | 347 |
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyEllipticKeyPair.java | 355 |
theCoder = new BouncyDSTUCoder(); } @Override public void initForSigning(final GordianKeyPair pKeyPair) throws GordianException { /* Initialise detail */ BouncyKeyPair.checkKeyPair(pKeyPair); super.initForSigning(pKeyPair); /* Initialise and set the signer */ final BouncyECPrivateKey myPrivate = (BouncyECPrivateKey) getKeyPair().getPrivateKey(); final ParametersWithRandom myParms = new ParametersWithRandom(myPrivate.getPrivateKey(), getRandom()); theSigner.init(true, myParms); } @Override public void initForVerify(final GordianKeyPair pKeyPair) throws GordianException { /* Initialise detail */ BouncyKeyPair.checkKeyPair(pKeyPair); super.initForVerify(pKeyPair); /* Initialise and set the signer */ final BouncyECPublicKey myPublic = (BouncyECPublicKey) getKeyPair().getPublicKey(); theSigner.init(false, myPublic.getPublicKey()); } @Override public byte[] sign() throws GordianException { /* Check that we are in signing mode */ checkMode(GordianSignatureMode.SIGN); /* Sign the message */ final BigInteger[] myValues = theSigner.generateSignature(getDigest()); return theCoder.dsaEncode(myValues[0], myValues[1]); } @Override public boolean verify(final byte[] pSignature) throws GordianException { /* Check that we are in verify mode */ checkMode(GordianSignatureMode.VERIFY); /* Verify the message */ final BigInteger[] myValues = theCoder.dsaDecode(pSignature); return theSigner.verifySignature(getDigest(), myValues[0], myValues[1]); } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyEllipticKeyPair.java | 355 |
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyGOSTKeyPair.java | 388 |
theCoder = new BouncyDERCoder(); } @Override public void initForSigning(final GordianKeyPair pKeyPair) throws GordianException { /* Initialise detail */ BouncyKeyPair.checkKeyPair(pKeyPair); super.initForSigning(pKeyPair); /* Initialise and set the signer */ final BouncyECPrivateKey myPrivate = (BouncyECPrivateKey) getKeyPair().getPrivateKey(); final ParametersWithRandom myParms = new ParametersWithRandom(myPrivate.getPrivateKey(), getRandom()); theSigner.init(true, myParms); } @Override public void initForVerify(final GordianKeyPair pKeyPair) throws GordianException { /* Initialise detail */ BouncyKeyPair.checkKeyPair(pKeyPair); super.initForVerify(pKeyPair); /* Initialise and set the signer */ final BouncyECPublicKey myPublic = (BouncyECPublicKey) getKeyPair().getPublicKey(); theSigner.init(false, myPublic.getPublicKey()); } @Override public byte[] sign() throws GordianException { /* Check that we are in signing mode */ checkMode(GordianSignatureMode.SIGN); /* Sign the message */ final BigInteger[] myValues = theSigner.generateSignature(getDigest()); return theCoder.dsaEncode(myValues[0], myValues[1]); } @Override public boolean verify(final byte[] pSignature) throws GordianException { /* Check that we are in verify mode */ checkMode(GordianSignatureMode.VERIFY); /* Verify the message */ final BigInteger[] myValues = theCoder.dsaDecode(pSignature); return theSigner.verifySignature(getDigest(), myValues[0], myValues[1]); } } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyDSTUKeyPair.java | 347 |
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyGOSTKeyPair.java | 388 |
theCoder = new BouncyDSTUCoder(); } @Override public void initForSigning(final GordianKeyPair pKeyPair) throws GordianException { /* Initialise detail */ BouncyKeyPair.checkKeyPair(pKeyPair); super.initForSigning(pKeyPair); /* Initialise and set the signer */ final BouncyECPrivateKey myPrivate = (BouncyECPrivateKey) getKeyPair().getPrivateKey(); final ParametersWithRandom myParms = new ParametersWithRandom(myPrivate.getPrivateKey(), getRandom()); theSigner.init(true, myParms); } @Override public void initForVerify(final GordianKeyPair pKeyPair) throws GordianException { /* Initialise detail */ BouncyKeyPair.checkKeyPair(pKeyPair); super.initForVerify(pKeyPair); /* Initialise and set the signer */ final BouncyECPublicKey myPublic = (BouncyECPublicKey) getKeyPair().getPublicKey(); theSigner.init(false, myPublic.getPublicKey()); } @Override public byte[] sign() throws GordianException { /* Check that we are in signing mode */ checkMode(GordianSignatureMode.SIGN); /* Sign the message */ final BigInteger[] myValues = theSigner.generateSignature(getDigest()); return theCoder.dsaEncode(myValues[0], myValues[1]); } @Override public boolean verify(final byte[] pSignature) throws GordianException { /* Check that we are in verify mode */ checkMode(GordianSignatureMode.VERIFY); /* Verify the message */ final BigInteger[] myValues = theCoder.dsaDecode(pSignature); return theSigner.verifySignature(getDigest(), myValues[0], myValues[1]); } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyEdDSAKeyPair.java | 464 |
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyMLDSAKeyPair.java | 325 |
final BouncyPublicKey<?> myPublic = getKeyPair().getPublicKey(); theSigner.init(false, myPublic.getPublicKey()); } @Override public void update(final byte[] pBytes, final int pOffset, final int pLength) { theSigner.update(pBytes, pOffset, pLength); } @Override public void update(final byte pByte) { theSigner.update(pByte); } @Override public void update(final byte[] pBytes) { theSigner.update(pBytes, 0, pBytes.length); } @Override public void reset() { theSigner.reset(); } @Override protected BouncyKeyPair getKeyPair() { return (BouncyKeyPair) super.getKeyPair(); } @Override public BouncyFactory getFactory() { return (BouncyFactory) super.getFactory(); } @Override public byte[] sign() throws GordianException { /* Check that we are in signing mode */ checkMode(GordianSignatureMode.SIGN); /* Sign the message */ try { return theSigner.generateSignature(); } catch (CryptoException e) { throw new GordianCryptoException(BouncySignature.ERROR_SIGGEN, e); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\jca\JcaKeyPairGenerator.java | 1255 |
net\sourceforge\joceanus\gordianknot\impl\jca\JcaKeyPairGenerator.java | 1466 |
} @Override public JcaKeyPair generateKeyPair() { /* Generate and return the keyPair */ final KeyPair myPair = theGenerator.generateKeyPair(); final JcaPublicKey myPublic = createPublic(myPair.getPublic()); final JcaStateAwarePrivateKey myPrivate = createPrivate(myPair.getPrivate()); return new JcaStateAwareKeyPair(myPublic, myPrivate); } @Override protected JcaStateAwarePrivateKey createPrivate(final PrivateKey pPrivateKey) { return new JcaStateAwarePrivateKey(getKeySpec(), pPrivateKey); } @Override public JcaKeyPair deriveKeyPair(final X509EncodedKeySpec pPublicKey, final PKCS8EncodedKeySpec pPrivateKey) throws GordianException { /* Protect against exceptions */ try { /* Check the keySpecs */ checkKeySpec(pPrivateKey); /* derive keyPair */ final JcaPublicKey myPublic = derivePublicKey(pPublicKey); JcaStateAwarePrivateKey myPrivate = createPrivate(getKeyFactory().generatePrivate(pPrivateKey)); final JcaKeyPair myPair = new JcaStateAwareKeyPair(myPublic, myPrivate); /* Check that we have a matching pair */ GordianKeyPairValidity.checkValidity(getFactory(), myPair); /* Rebuild and return the keyPair to avoid incrementing usage count */ myPrivate = createPrivate(getKeyFactory().generatePrivate(pPrivateKey)); return new JcaStateAwareKeyPair(myPublic, myPrivate); } catch (InvalidKeySpecException e) { throw new GordianCryptoException(PARSE_ERROR, e); } } } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\macs\GordianBlake2XMac.java | 74 |
net\sourceforge\joceanus\gordianknot\impl\ext\macs\GordianSkeinXMac.java | 127 |
return theXof.getDigestSize(); } @Override public void update(final byte in) { theXof.update(in); } @Override public void update(final byte[] in, final int inOff, final int len) { theXof.update(in, inOff, len); } @Override public int doFinal(final byte[] out, final int outOff) { return theXof.doFinal(out, outOff); } @Override public int doFinal(final byte[] out, final int outOff, final int outLen) { return theXof.doFinal(out, outOff, outLen); } @Override public int doOutput(final byte[] out, final int outOff, final int outLen) { return theXof.doOutput(out, outOff, outLen); } @Override public int getByteLength() { return theXof.getByteLength(); } @Override public int getDigestSize() { return theXof.getDigestSize(); } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSimonEngine.java | 149 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSpeckEngine.java | 103 |
} @Override public int getBlockSize() { return BLOCKSIZE; } @Override public int processBlock(final byte[] pInput, final int pInOff, final byte[] pOutput, final int pOutOff) { /* Check buffers */ if (pInput == null || pInput.length - pInOff < BLOCKSIZE) { throw new IllegalArgumentException("Invalid input buffer"); } if (pOutput == null || pOutput.length - pOutOff < BLOCKSIZE) { throw new IllegalArgumentException("Invalid output buffer"); } /* Perform the encryption/decryption */ return forEncryption ? encryptBlock(pInput, pInOff, pOutput, pOutOff) : decryptBlock(pInput, pInOff, pOutput, pOutOff); } /** * Encrypt a block. * @param pInput the input buffer * @param pInOff the input offset * @param pOutput the output offset * @param pOutOff the output offset * @return the bytes processed */ private int encryptBlock(final byte[] pInput, final int pInOff, final byte[] pOutput, final int pOutOff) { /* Load the bytes into the block */ long myX = Pack.bigEndianToLong(pInput, pInOff); long myY = Pack.bigEndianToLong(pInput, pInOff + Long.BYTES); /* Loop through the rounds */ for (int i = 0; i < theRounds; i++) { |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianBlake2Xof.java | 158 |
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianSkeinXof.java | 163 |
return theUnderlying.getByteLength(); } @Override public void update(final byte b) { singleByte[0] = b; update(singleByte, 0, 1); } @Override public void update(final byte[] pMessage, final int pOffset, final int pLen) { if (theXofRemaining != -1) { throw new IllegalStateException("Already outputting"); } theUnderlying.update(pMessage, pOffset, pLen); } @Override public int doFinal(final byte[] pOut, final int pOutOffset) { return doFinal(pOut, pOutOffset, getDigestSize()); } @Override public int doFinal(final byte[] pOut, final int pOutOffset, final int pOutLen) { /* Build the required output */ final int length = doOutput(pOut, pOutOffset, pOutLen); /* reset the underlying digest and return the length */ reset(); return length; } @Override public int doOutput(final byte[] pOut, final int pOutOffset, final int pOutLen) { /* If we have not created the root hash yet */ if (theRoot == null) { |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyRSAKeyPair.java | 606 |
net\sourceforge\joceanus\gordianknot\impl\bc\BouncySM2KeyPair.java | 331 |
theEncryptor = new OAEPEncoding(pEngine, myDigest.getDigest(), PSource.PSpecified.DEFAULT.getValue()); } @Override protected BouncyPublicKey<?> getPublicKey() { return (BouncyPublicKey<?>) super.getPublicKey(); } @Override protected BouncyPrivateKey<?> getPrivateKey() { return (BouncyPrivateKey<?>) super.getPrivateKey(); } @Override public void initForEncrypt(final GordianKeyPair pKeyPair) throws GordianException { /* Initialise underlying cipher */ BouncyKeyPair.checkKeyPair(pKeyPair); super.initForEncrypt(pKeyPair); /* Initialise for encryption */ final ParametersWithRandom myParms = new ParametersWithRandom(getPublicKey().getPublicKey(), getRandom()); theEncryptor.init(true, myParms); } @Override public void initForDecrypt(final GordianKeyPair pKeyPair) throws GordianException { /* Initialise underlying cipher */ BouncyKeyPair.checkKeyPair(pKeyPair); super.initForDecrypt(pKeyPair); /* Initialise for decryption */ theEncryptor.init(false, getPrivateKey().getPrivateKey()); } @Override public byte[] encrypt(final byte[] pBytes) throws GordianException { |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianBlake2Tree.java | 478 |
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianSkeinTree.java | 554 |
theDigest.doFinal(theResult, 0); myResults.addElement(Arrays.clone(theResult)); /* Return the results */ return myResults; } /** * Check the leaf index. * @param pIndex the index of the element * @return is this the last element in the tree? true/false */ boolean checkLeafIndex(final int pIndex) { /* Cannot replace leaf if not built */ if (!treeBuilt) { throw new IllegalStateException("Tree has not been built"); } /* Check that the index is valid */ final SimpleVector myLevel = (SimpleVector) theHashes.firstElement(); if (pIndex < 0 || pIndex >= myLevel.size()) { throw new IllegalArgumentException("Invalid index"); } /* Return whether this is the last index */ return pIndex == myLevel.size() - 1; } /** * Replace the hash for a leaf node. * @param pIndex the index of the element * @param pHash the new hashValue */ void replaceElement(final int pIndex, final byte[] pHash) { /* Check that the index is correct */ final SimpleVector myLevel = (SimpleVector) theHashes.firstElement(); if (pIndex < 0 || pIndex >= myLevel.size()) { throw new IllegalArgumentException("Invalid index"); } /* Replace the element */ myLevel.setElementAt(Arrays.clone(pHash), pIndex); /* Loop through the levels */ int myIndex = pIndex; for (int i = 1; i < theHashes.size(); i++) { |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\macs\GordianZuc128Mac.java | 108 |
net\sourceforge\joceanus\gordianknot\impl\ext\macs\GordianZuc256Mac.java | 119 |
for (int i = 0; i < theKeyStream.length - 1; i++) { theKeyStream[i] = theEngine.makeKeyStreamWord(); } theWordIndex = theKeyStream.length - 1; theByteIndex = Integer.BYTES - 1; } /** * Update the mac with a single byte. * @param in the byte to update with */ public void update(final byte in) { /* shift for next byte */ shift4NextByte(); /* Loop through the bits */ final int bitBase = theByteIndex * Byte.SIZE; for (int bitMask = TOPBIT, bitNo = 0; bitMask > 0; bitMask >>= 1, bitNo++) { /* If the bit is set */ if ((in & bitMask) != 0) { /* update theMac */ updateMac(bitBase + bitNo); } } } /** * Shift for next byte. */ private void shift4NextByte() { /* Adjust the byte index */ theByteIndex = (theByteIndex + 1) % Integer.BYTES; /* Adjust keyStream if required */ if (theByteIndex == 0) { theKeyStream[theWordIndex] = theEngine.makeKeyStreamWord(); theWordIndex = (theWordIndex + 1) % theKeyStream.length; } } /** * Update the Mac. * @param bitNo the bit number */ private void updateMac(final int bitNo) { |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyDSTUKeyPair.java | 166 |
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyGOSTKeyPair.java | 171 |
final BCDSTU4145PrivateKey privKey = new BCDSTU4145PrivateKey(ALGO, myParms, pubKey, theSpec); return new PKCS8EncodedKeySpec(privKey.getEncoded()); } @Override public BouncyKeyPair deriveKeyPair(final X509EncodedKeySpec pPublicKey, final PKCS8EncodedKeySpec pPrivateKey) throws GordianException { /* Check the keySpecs */ checkKeySpec(pPrivateKey); /* derive keyPair */ final BouncyECPublicKey myPublic = derivePublicKey(pPublicKey); final PrivateKeyInfo myInfo = PrivateKeyInfo.getInstance(pPrivateKey.getEncoded()); final ECPrivateKeyParameters myParms = deriveFromPrivKeyInfo(myInfo); final BouncyECPrivateKey myPrivate = new BouncyECPrivateKey(getKeySpec(), myParms); final BouncyKeyPair myPair = new BouncyKeyPair(myPublic, myPrivate); /* Check that we have a matching pair */ GordianKeyPairValidity.checkValidity(getFactory(), myPair); /* Return the keyPair */ return myPair; } @Override public X509EncodedKeySpec getX509Encoding(final GordianKeyPair pKeyPair) throws GordianException { /* Check the keyPair type and keySpecs */ BouncyKeyPair.checkKeyPair(pKeyPair, getKeySpec()); /* build and return the encoding */ final BouncyECPublicKey myPublicKey = (BouncyECPublicKey) getPublicKey(pKeyPair); final ECPublicKeyParameters myParms = myPublicKey.getPublicKey(); final BCDSTU4145PublicKey pubKey = new BCDSTU4145PublicKey(ALGO, myParms, theSpec); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSimonEngine.java | 96 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSpeckEngine.java | 50 |
private static final int ROT3 = 3; /** * Rotate8. */ private static final int ROT8 = 8; /** * The # of rounds. */ private int theRounds; /** * The expanded key schedule. */ private long[] theRoundKeys; /** * Are we encrypting? */ private boolean forEncryption; @Override public void init(final boolean pEncrypt, final CipherParameters pParams) { /* Reject invalid parameters */ if (!(pParams instanceof KeyParameter)) { throw new IllegalArgumentException("Invalid parameter passed to Speck init - " + pParams.getClass().getName()); } /* Validate keyLength */ final byte[] myKey = ((KeyParameter) pParams).getKey(); final int myKeyLen = myKey.length; if ((((myKeyLen << 1) % BLOCKSIZE) != 0) || myKeyLen < BLOCKSIZE || myKeyLen > (BLOCKSIZE << 1)) { throw new IllegalArgumentException("KeyBitSize must be 128, 192 or 256"); } /* Generate the round keys */ forEncryption = pEncrypt; generateRoundKeys(myKey); } @Override public void reset() { /* NoOp */ } @Override public String getAlgorithmName() { return "Simon"; |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianCubeHashDigest.java | 203 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianRabbitEngine.java | 198 |
} /** * Decode a 32-bit value from a buffer (little-endian). * * @param buf the input buffer * @param off the input offset * @return the decoded value */ private static int decode32le(final byte[] buf, final int off) { return (buf[off] & 0xFF) | ((buf[off + 1] & 0xFF) << 8) | ((buf[off + 2] & 0xFF) << 16) | ((buf[off + 3] & 0xFF) << 24); } /** * Encode a 32-bit value into a buffer (little-endian). * * @param val the value to encode * @param buf the output buffer * @param off the output offset */ private static void encode32le(final int val, final byte[] buf, final int off) { buf[off] = (byte) val; buf[off + 1] = (byte) (val >> 8); buf[off + 2] = (byte) (val >> 16); buf[off + 3] = (byte) (val >> 24); } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianCubeHashDigest.java | 212 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 253 |
private static int decode32le(final byte[] buf, final int off) { return (buf[off] & 0xFF) | ((buf[off + 1] & 0xFF) << 8) | ((buf[off + 2] & 0xFF) << 16) | ((buf[off + 3] & 0xFF) << 24); } /** * Encode a 32-bit value into a buffer (little-endian). * * @param val the value to encode * @param buf the output buffer * @param off the output offset */ private static void encode32le(final int val, final byte[] buf, final int off) { buf[off] = (byte) val; buf[off + 1] = (byte) (val >> 8); buf[off + 2] = (byte) (val >> 16); buf[off + 3] = (byte) (val >> 24); } /** * Process a block. */ private void processBlock() { |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianRabbitEngine.java | 207 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 253 |
private static int decode32le(final byte[] buf, final int off) { return (buf[off] & 0xFF) | ((buf[off + 1] & 0xFF) << 8) | ((buf[off + 2] & 0xFF) << 16) | ((buf[off + 3] & 0xFF) << 24); } /** * Encode a 32-bit value into a buffer (little-endian). * * @param val the value to encode * @param buf the output buffer * @param off the output offset */ private static void encode32le(final int val, final byte[] buf, final int off) { buf[off] = (byte) val; buf[off + 1] = (byte) (val >> 8); buf[off + 2] = (byte) (val >> 16); buf[off + 3] = (byte) (val >> 24); } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyDSTUKeyPair.java | 142 |
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyGOSTKeyPair.java | 147 |
new ECDomainParameters(myCurve, myG, theSpec.getOrder(), BigInteger.valueOf(theSpec.getCofactor())), getRandom()); theGenerator.init(myParams); } @Override public BouncyKeyPair generateKeyPair() { /* Generate and return the keyPair */ final AsymmetricCipherKeyPair myPair = theGenerator.generateKeyPair(); final BouncyECPublicKey myPublic = new BouncyECPublicKey(getKeySpec(), (ECPublicKeyParameters) myPair.getPublic()); final BouncyECPrivateKey myPrivate = new BouncyECPrivateKey(getKeySpec(), (ECPrivateKeyParameters) myPair.getPrivate()); return new BouncyKeyPair(myPublic, myPrivate); } @Override public PKCS8EncodedKeySpec getPKCS8Encoding(final GordianKeyPair pKeyPair) throws GordianException { /* Check the keyPair type and keySpecs */ BouncyKeyPair.checkKeyPair(pKeyPair, getKeySpec()); /* build and return the encoding */ final BouncyECPrivateKey myPrivateKey = (BouncyECPrivateKey) getPrivateKey(pKeyPair); final ECPrivateKeyParameters myParms = myPrivateKey.getPrivateKey(); final BouncyECPublicKey myPublicKey = (BouncyECPublicKey) getPublicKey(pKeyPair); final ECPublicKeyParameters myPubParms = myPublicKey.getPublicKey(); final BCDSTU4145PublicKey pubKey = new BCDSTU4145PublicKey(ALGO, myPubParms, theSpec); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSnow3GEngine.java | 409 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSnow3GEngine.java | 438 |
^ (f) ); lfsrState[0] = lfsrState[1]; lfsrState[1] = lfsrState[2]; lfsrState[2] = lfsrState[3]; lfsrState[3] = lfsrState[4]; lfsrState[4] = lfsrState[5]; lfsrState[5] = lfsrState[6]; lfsrState[6] = lfsrState[7]; lfsrState[7] = lfsrState[8]; lfsrState[8] = lfsrState[9]; lfsrState[9] = lfsrState[10]; lfsrState[10] = lfsrState[11]; lfsrState[11] = lfsrState[12]; lfsrState[12] = lfsrState[13]; lfsrState[13] = lfsrState[14]; lfsrState[14] = lfsrState[15]; lfsrState[15] = v; } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianJHDigest.java | 685 |
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianJHDigest.java | 713 |
buffer[63] = (byte) (databitlen & 0xff); buffer[62] = (byte) ((databitlen >> 8) & 0xff); buffer[61] = (byte) ((databitlen >> 16) & 0xff); buffer[60] = (byte) ((databitlen >> 24) & 0xff); buffer[59] = (byte) ((databitlen >> 32) & 0xff); buffer[58] = (byte) ((databitlen >> 40) & 0xff); buffer[57] = (byte) ((databitlen >> 48) & 0xff); buffer[56] = (byte) ((databitlen >> 56) & 0xff); f8(); } else { |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianBlake2XEngine.java | 121 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianBlake3Engine.java | 115 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSkeinXofEngine.java | 122 |
return theBlake2X.getAlgorithmName(); } @Override public int processBytes(final byte[] in, final int inOff, final int len, final byte[] out, final int outOff) { /* Check for errors */ if (theResetState == null) { throw new IllegalStateException(getAlgorithmName() + " not initialised"); } if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + len) > out.length) { throw new OutputLengthException("output buffer too short"); } /* Loop through the input bytes */ for (int i = 0; i < len; i++) { out[i + outOff] = returnByte(in[i + inOff]); } return len; } @Override public void reset() { if (theResetState != null) { |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSnow3GEngine.java | 410 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianZuc128Engine.java | 331 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianZuc128Engine.java | 366 |
); lfsrState[0] = lfsrState[1]; lfsrState[1] = lfsrState[2]; lfsrState[2] = lfsrState[3]; lfsrState[3] = lfsrState[4]; lfsrState[4] = lfsrState[5]; lfsrState[5] = lfsrState[6]; lfsrState[6] = lfsrState[7]; lfsrState[7] = lfsrState[8]; lfsrState[8] = lfsrState[9]; lfsrState[9] = lfsrState[10]; lfsrState[10] = lfsrState[11]; lfsrState[11] = lfsrState[12]; lfsrState[12] = lfsrState[13]; lfsrState[13] = lfsrState[14]; lfsrState[14] = lfsrState[15]; lfsrState[15] = v; |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSnow3GEngine.java | 439 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianZuc128Engine.java | 331 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianZuc128Engine.java | 366 |
); lfsrState[0] = lfsrState[1]; lfsrState[1] = lfsrState[2]; lfsrState[2] = lfsrState[3]; lfsrState[3] = lfsrState[4]; lfsrState[4] = lfsrState[5]; lfsrState[5] = lfsrState[6]; lfsrState[6] = lfsrState[7]; lfsrState[7] = lfsrState[8]; lfsrState[8] = lfsrState[9]; lfsrState[9] = lfsrState[10]; lfsrState[10] = lfsrState[11]; lfsrState[11] = lfsrState[12]; lfsrState[12] = lfsrState[13]; lfsrState[13] = lfsrState[14]; lfsrState[14] = lfsrState[15]; lfsrState[15] = v; |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyDSTUKeyPair.java | 347 |
net\sourceforge\joceanus\gordianknot\impl\bc\BouncySM2KeyPair.java | 130 |
theCoder = new BouncyDSTUCoder(); } @Override public void initForSigning(final GordianKeyPair pKeyPair) throws GordianException { /* Initialise detail */ BouncyKeyPair.checkKeyPair(pKeyPair); super.initForSigning(pKeyPair); /* Initialise and set the signer */ final BouncyECPrivateKey myPrivate = (BouncyECPrivateKey) getKeyPair().getPrivateKey(); final ParametersWithRandom myParms = new ParametersWithRandom(myPrivate.getPrivateKey(), getRandom()); theSigner.init(true, myParms); } @Override public void initForVerify(final GordianKeyPair pKeyPair) throws GordianException { /* Initialise detail */ BouncyKeyPair.checkKeyPair(pKeyPair); super.initForVerify(pKeyPair); /* Initialise and set the signer */ final BouncyECPublicKey myPublic = (BouncyECPublicKey) getKeyPair().getPublicKey(); theSigner.init(false, myPublic.getPublicKey()); } @Override public byte[] sign() throws GordianException { /* Check that we are in signing mode */ checkMode(GordianSignatureMode.SIGN); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianBlake2XEngine.java | 122 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianRabbitEngine.java | 156 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSkeinXofEngine.java | 123 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSnow3GEngine.java | 201 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 109 |
} @Override public int processBytes(final byte[] in, final int inOff, final int len, final byte[] out, final int outOff) { /* Check for errors */ if (theResetState == null) { throw new IllegalStateException(getAlgorithmName() + " not initialised"); } if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + len) > out.length) { throw new OutputLengthException("output buffer too short"); } /* Loop through the input bytes */ for (int i = 0; i < len; i++) { out[i + outOff] = returnByte(in[i + inOff]); } return len; } @Override public void reset() { if (theResetState != null) { |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianBlake3Engine.java | 116 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianRabbitEngine.java | 156 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSnow3GEngine.java | 201 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 109 |
} @Override public int processBytes(final byte[] in, final int inOff, final int len, final byte[] out, final int outOff) { /* Check for errors */ if (theResetState == null) { throw new IllegalStateException(getAlgorithmName() + " not initialised"); } if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + len) > out.length) { throw new OutputLengthException("output buffer too short"); } /* Loop through the input bytes */ for (int i = 0; i < len; i++) { out[i + outOff] = returnByte(in[i + inOff]); } return len; } @Override public void reset() { if (theResetState != null) { |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyGOSTKeyPair.java | 388 |
net\sourceforge\joceanus\gordianknot\impl\bc\BouncySM2KeyPair.java | 130 |
theCoder = new BouncyGOSTCoder(pSpec.getDigestSpec().getDigestLength().getByteLength() << 1); } @Override public void initForSigning(final GordianKeyPair pKeyPair) throws GordianException { /* Initialise detail */ BouncyKeyPair.checkKeyPair(pKeyPair); super.initForSigning(pKeyPair); /* Initialise and set the signer */ final BouncyECPrivateKey myPrivate = (BouncyECPrivateKey) getKeyPair().getPrivateKey(); final ParametersWithRandom myParms = new ParametersWithRandom(myPrivate.getPrivateKey(), getRandom()); theSigner.init(true, myParms); } @Override public void initForVerify(final GordianKeyPair pKeyPair) throws GordianException { /* Initialise detail */ BouncyKeyPair.checkKeyPair(pKeyPair); super.initForVerify(pKeyPair); /* Initialise and set the signer */ final BouncyECPublicKey myPublic = (BouncyECPublicKey) getKeyPair().getPublicKey(); theSigner.init(false, myPublic.getPublicKey()); } @Override public byte[] sign() throws GordianException { /* Check that we are in signing mode */ checkMode(GordianSignatureMode.SIGN); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\macs\GordianSkeinMac.java | 87 |
net\sourceforge\joceanus\gordianknot\impl\ext\macs\GordianSkeinXMac.java | 94 |
return "Skein-MAC-" + (theEngine.getBlockSize() * Byte.SIZE) + "-" + (theEngine.getOutputSize() * Byte.SIZE); } /** * Initialises the Skein digest with the provided parameters.<br> * See {@link GordianSkeinParameters} for details on the parameterisation of the Skein hash function. * * @param params an instance of {@link GordianSkeinParameters} or {@link KeyParameter}. */ public void init(final CipherParameters params) throws IllegalArgumentException { final GordianSkeinParameters skeinParameters; if (params instanceof GordianSkeinParameters) { skeinParameters = (GordianSkeinParameters) params; } else if (params instanceof KeyParameter) { skeinParameters = new GordianSkeinParametersBuilder().setKey(((KeyParameter) params).getKey()).build(); } else { throw new IllegalArgumentException("Invalid parameter passed to Skein MAC init - " + params.getClass().getName()); } if (skeinParameters.getKey() == null) { throw new IllegalArgumentException("Skein MAC requires a key parameter."); } theEngine.init(skeinParameters); } @Override public int getMacSize() { return theEngine.getOutputSize(); } @Override public void reset() { |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianBlake2Tree.java | 238 |
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianSkeinTree.java | 285 |
theStore.init(pParams); } /** * Update leaf. * @param pIndex the index of the leaf * @param pInput the input buffer * @param pInOffSet the starting offset the the input buffer */ public void updateLeaf(final int pIndex, final byte[] pInput, final int pInOffSet) { /* Full leafLen */ updateLeaf(pIndex, pInput, pInOffSet, getLeafLen()); } /** * Update leaf. * @param pIndex the index of the leaf * @param pInput the input buffer * @param pInOffSet the starting offset the the input buffer * @param pLen the length of data */ public void updateLeaf(final int pIndex, final byte[] pInput, final int pInOffSet, final int pLen) { /* Check index validity */ final boolean bLast = theStore.checkLeafIndex(pIndex); /* Validate the leaf length */ final int myLeafLen = getLeafLen(); if (pLen < 0 || pLen > myLeafLen) { throw new DataLengthException("Invalid length"); } /* Any leaf that is not the last must be leafLen in length */ if (!bLast && pLen != myLeafLen) { throw new DataLengthException("All but the last leaf must have byteLength " + myLeafLen); } /* Make sure that the buffer is valid */ if (pLen + pInOffSet > pInput.length) { throw new DataLengthException("Invalid input buffer"); } /* Initialise the node and note if last node */ theDigest.setNodePosition(pIndex, 0); |
File | Line |
---|---|
org\bouncycastle\crypto\patch\digests\GordianAsconHash256.java | 20 |
org\bouncycastle\crypto\patch\digests\GordianAsconXof128.java | 37 |
} protected long pad(int i) { return 0x01L << (i << 3); } protected long loadBytes(final byte[] bytes, int inOff) { return GordianPack.littleEndianToLong(bytes, inOff); } protected long loadBytes(final byte[] bytes, int inOff, int n) { return GordianPack.littleEndianToLong(bytes, inOff, n); } protected void setBytes(long w, byte[] bytes, int inOff) { GordianPack.longToLittleEndian(w, bytes, inOff); } protected void setBytes(long w, byte[] bytes, int inOff, int n) { GordianPack.longToLittleEndian(w, bytes, inOff, n); } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\jca\JcaSignature.java | 399 |
net\sourceforge\joceanus\gordianknot\impl\jca\JcaSignature.java | 455 |
JcaSLHDSASignature(final GordianCoreFactory pFactory, final GordianSignatureSpec pSignatureSpec) throws GordianException { /* Initialise class */ super(pFactory, pSignatureSpec); } @Override public void initForSigning(final GordianKeyPair pKeyPair) throws GordianException { /* Determine the required signer */ JcaKeyPair.checkKeyPair(pKeyPair); final String mySignName = getAlgorithmForKeyPair(pKeyPair); setSigner(JcaSignatureFactory.getJavaSignature(mySignName, false)); /* pass on call */ super.initForSigning(pKeyPair); } @Override public void initForVerify(final GordianKeyPair pKeyPair) throws GordianException { /* Determine the required signer */ JcaKeyPair.checkKeyPair(pKeyPair); final String mySignName = getAlgorithmForKeyPair(pKeyPair); setSigner(JcaSignatureFactory.getJavaSignature(mySignName, false)); /* pass on call */ super.initForVerify(pKeyPair); } /** * Obtain algorithmName for keyPair. * @param pKeyPair the keyPair * @return the name */ private static String getAlgorithmForKeyPair(final GordianKeyPair pKeyPair) { /* Build the algorithm */ final boolean isHash = pKeyPair.getKeyPairSpec().getSLHDSAKeySpec().isHash(); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 567 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 843 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 1119 |
tt = w7 ^ w2 ^ w4 ^ w6 ^ (0x9E3779B9 ^ (28 + 3)); w7 = rotateLeft(tt, 11); r0 = w4; r1 = w5; r2 = w6; r3 = w7; r1 ^= r3; r3 = ~r3; r2 ^= r3; r3 ^= r0; r4 = r1; r1 &= r3; r1 ^= r2; r4 ^= r3; r0 ^= r4; r2 &= r4; r2 ^= r0; r0 &= r1; r3 ^= r0; r4 |= r1; r4 ^= r0; r0 |= r3; r0 ^= r2; r2 &= r3; r0 = ~r0; r4 ^= r2; serpent24SubKeys[i++] = r1; serpent24SubKeys[i++] = r4; serpent24SubKeys[i++] = r0; serpent24SubKeys[i++] = r3; tt = w0 ^ w3 ^ w5 ^ w7 ^ (0x9E3779B9 ^ (32)); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 462 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 738 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 1014 |
tt = w3 ^ w6 ^ w0 ^ w2 ^ (0x9E3779B9 ^ (16 + 3)); w3 = rotateLeft(tt, 11); r0 = w0; r1 = w1; r2 = w2; r3 = w3; r4 = r1; r1 |= r2; r1 ^= r3; r4 ^= r2; r2 ^= r1; r3 |= r4; r3 &= r0; r4 ^= r2; r3 ^= r1; r1 |= r4; r1 ^= r0; r0 |= r4; r0 ^= r2; r1 ^= r4; r2 ^= r1; r1 &= r0; r1 ^= r4; r2 = ~r2; r2 |= r0; r4 ^= r2; serpent24SubKeys[i++] = r4; serpent24SubKeys[i++] = r3; serpent24SubKeys[i++] = r1; serpent24SubKeys[i++] = r0; tt = w4 ^ w7 ^ w1 ^ w3 ^ (0x9E3779B9 ^ (20)); |
File | Line |
---|---|
SevenZip\Compression\LZ\BinTree.java | 200 |
SevenZip\Compression\LZ\BinTree.java | 296 |
int count = _cutValue; while (true) { if (curMatch <= matchMinPos || count-- == 0) { _son[ptr0] = _son[ptr1] = kEmptyHashValue; break; } int delta = _pos - curMatch; int cyclicPos = ((delta <= _cyclicBufferPos) ? (_cyclicBufferPos - delta) : (_cyclicBufferPos - delta + _cyclicBufferSize)) << 1; int pby1 = _bufferOffset + curMatch; int len = Math.min(len0, len1); if (_bufferBase[pby1 + len] == _bufferBase[cur + len]) { while(++len != lenLimit) if (_bufferBase[pby1 + len] != _bufferBase[cur + len]) break; if (maxLen < len) |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianBlake2Tree.java | 357 |
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianSkeinTree.java | 431 |
theHashes.clear(); treeBuilt = false; } /** * Add intermediate node. * @param pHash the intermediate hash */ void addElement(final byte[] pHash) { /* Access the base level */ if (theHashes.isEmpty()) { theHashes.addElement(new SimpleVector()); } final SimpleVector myLevel = (SimpleVector) theHashes.firstElement(); /* Add the element to the vector */ myLevel.addElement(Arrays.clone(pHash)); } /** * Obtain the tree result. * @param pOut the output buffer * @param pOutOffset the offset into the output buffer * @return the number of bytes returned */ int obtainResult(final byte[] pOut, final int pOutOffset) { /* Check parameters */ if (pOut.length < pOutOffset + theResult.length) { throw new OutputLengthException("Insufficient output buffer"); } if (!treeBuilt) { throw new IllegalStateException("tree has not been built"); } /* Access the final level */ final SimpleVector myLevel = (SimpleVector) theHashes.lastElement(); final byte[] myResult = (byte[]) myLevel.firstElement(); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 532 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 808 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 1084 |
tt = w3 ^ w6 ^ w0 ^ w2 ^ (0x9E3779B9 ^ (24 + 3)); w3 = rotateLeft(tt, 11); r0 = w0; r1 = w1; r2 = w2; r3 = w3; r0 ^= r1; r1 ^= r3; r3 = ~r3; r4 = r1; r1 &= r0; r2 ^= r3; r1 ^= r2; r2 |= r4; r4 ^= r3; r3 &= r1; r3 ^= r0; r4 ^= r1; r4 ^= r2; r2 ^= r0; r0 &= r3; r2 = ~r2; r0 ^= r4; r4 |= r3; r2 ^= r4; serpent24SubKeys[i++] = r1; serpent24SubKeys[i++] = r3; serpent24SubKeys[i++] = r0; serpent24SubKeys[i++] = r2; tt = w4 ^ w7 ^ w1 ^ w3 ^ (0x9E3779B9 ^ (28)); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyDSAKeyPair.java | 332 |
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyGOSTKeyPair.java | 410 |
final BouncyDSAPublicKey myPublic = (BouncyDSAPublicKey) getKeyPair().getPublicKey(); theSigner.init(false, myPublic.getPublicKey()); } @Override public byte[] sign() throws GordianException { /* Check that we are in signing mode */ checkMode(GordianSignatureMode.SIGN); /* Sign the message */ final BigInteger[] myValues = theSigner.generateSignature(getDigest()); return theCoder.dsaEncode(myValues[0], myValues[1]); } @Override public boolean verify(final byte[] pSignature) throws GordianException { /* Check that we are in verify mode */ checkMode(GordianSignatureMode.VERIFY); /* Verify the message */ final BigInteger[] myValues = theCoder.dsaDecode(pSignature); return theSigner.verifySignature(getDigest(), myValues[0], myValues[1]); } } } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyDSAKeyPair.java | 332 |
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyEllipticKeyPair.java | 377 |
final BouncyDSAPublicKey myPublic = (BouncyDSAPublicKey) getKeyPair().getPublicKey(); theSigner.init(false, myPublic.getPublicKey()); } @Override public byte[] sign() throws GordianException { /* Check that we are in signing mode */ checkMode(GordianSignatureMode.SIGN); /* Sign the message */ final BigInteger[] myValues = theSigner.generateSignature(getDigest()); return theCoder.dsaEncode(myValues[0], myValues[1]); } @Override public boolean verify(final byte[] pSignature) throws GordianException { /* Check that we are in verify mode */ checkMode(GordianSignatureMode.VERIFY); /* Verify the message */ final BigInteger[] myValues = theCoder.dsaDecode(pSignature); return theSigner.verifySignature(getDigest(), myValues[0], myValues[1]); } } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 603 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 879 |
tt = w3 ^ w6 ^ w0 ^ w2 ^ (0x9E3779B9 ^ (32 + 3)); w3 = rotateLeft(tt, 11); r0 = w0; r1 = w1; r2 = w2; r3 = w3; r4 = r0; r0 |= r3; r3 ^= r1; r1 &= r4; r4 ^= r2; r2 ^= r3; r3 &= r0; r4 |= r1; r3 ^= r4; r0 ^= r1; r4 &= r0; r1 ^= r3; r4 ^= r2; r1 |= r0; r1 ^= r2; r0 ^= r3; r2 = r1; r1 |= r3; r1 ^= r0; serpent24SubKeys[i++] = r1; serpent24SubKeys[i++] = r2; serpent24SubKeys[i++] = r3; serpent24SubKeys[i++] = r4; tt = w4 ^ w7 ^ w1 ^ w3 ^ (0x9E3779B9 ^ (36)); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyDSAKeyPair.java | 332 |
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyDSTUKeyPair.java | 369 |
final BouncyDSAPublicKey myPublic = (BouncyDSAPublicKey) getKeyPair().getPublicKey(); theSigner.init(false, myPublic.getPublicKey()); } @Override public byte[] sign() throws GordianException { /* Check that we are in signing mode */ checkMode(GordianSignatureMode.SIGN); /* Sign the message */ final BigInteger[] myValues = theSigner.generateSignature(getDigest()); return theCoder.dsaEncode(myValues[0], myValues[1]); } @Override public boolean verify(final byte[] pSignature) throws GordianException { /* Check that we are in verify mode */ checkMode(GordianSignatureMode.VERIFY); /* Verify the message */ final BigInteger[] myValues = theCoder.dsaDecode(pSignature); return theSigner.verifySignature(getDigest(), myValues[0], myValues[1]); } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 394 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 670 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 946 |
tt = w3 ^ w6 ^ w0 ^ w2 ^ (0x9E3779B9 ^ (8 + 3)); w3 = rotateLeft(tt, 11); r0 = w0; r1 = w1; r2 = w2; r3 = w3; r0 = ~r0; r2 = ~r2; r4 = r0; r0 &= r1; r2 ^= r0; r0 |= r3; r3 ^= r2; r1 ^= r0; r0 ^= r4; r4 |= r1; r1 ^= r3; r2 |= r0; r2 &= r4; r0 ^= r1; r1 &= r2; r1 ^= r0; r0 &= r2; r0 ^= r4; serpent24SubKeys[i++] = r2; serpent24SubKeys[i++] = r0; serpent24SubKeys[i++] = r3; serpent24SubKeys[i++] = r1; tt = w4 ^ w7 ^ w1 ^ w3 ^ (0x9E3779B9 ^ (12)); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 498 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 774 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 1050 |
tt = w7 ^ w2 ^ w4 ^ w6 ^ (0x9E3779B9 ^ (20 + 3)); w7 = rotateLeft(tt, 11); r0 = w4; r1 = w5; r2 = w6; r3 = w7; r2 = ~r2; r4 = r3; r3 &= r0; r0 ^= r4; r3 ^= r2; r2 |= r4; r1 ^= r3; r2 ^= r0; r0 |= r1; r2 ^= r1; r4 ^= r0; r0 |= r3; r0 ^= r2; r4 ^= r3; r4 ^= r0; r3 = ~r3; r2 &= r4; r2 ^= r3; serpent24SubKeys[i++] = r0; serpent24SubKeys[i++] = r1; serpent24SubKeys[i++] = r4; serpent24SubKeys[i++] = r2; tt = w0 ^ w3 ^ w5 ^ w7 ^ (0x9E3779B9 ^ (24)); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 428 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 704 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 980 |
tt = w7 ^ w2 ^ w4 ^ w6 ^ (0x9E3779B9 ^ (12 + 3)); w7 = rotateLeft(tt, 11); r0 = w4; r1 = w5; r2 = w6; r3 = w7; r3 ^= r0; r4 = r1; r1 &= r3; r4 ^= r2; r1 ^= r0; r0 |= r3; r0 ^= r4; r4 ^= r3; r3 ^= r2; r2 |= r1; r2 ^= r4; r4 = ~r4; r4 |= r1; r1 ^= r3; r1 ^= r4; r3 |= r0; r1 ^= r3; r4 ^= r3; serpent24SubKeys[i++] = r1; serpent24SubKeys[i++] = r4; serpent24SubKeys[i++] = r2; serpent24SubKeys[i++] = r0; tt = w0 ^ w3 ^ w5 ^ w7 ^ (0x9E3779B9 ^ (16)); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianBlake2XEngine.java | 125 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianZuc128Engine.java | 228 |
public int processBytes(final byte[] in, final int inOff, final int len, final byte[] out, final int outOff) { /* Check for errors */ if (theResetState == null) { throw new IllegalStateException(getAlgorithmName() + " not initialised"); } if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + len) > out.length) { throw new OutputLengthException("output buffer too short"); } /* Loop through the input bytes */ for (int i = 0; i < len; i++) { out[i + outOff] = returnByte(in[i + inOff]); } return len; } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianBlake3Engine.java | 119 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianZuc128Engine.java | 228 |
public int processBytes(final byte[] in, final int inOff, final int len, final byte[] out, final int outOff) { /* Check for errors */ if (theResetState == null) { throw new IllegalStateException(getAlgorithmName() + " not initialised"); } if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + len) > out.length) { throw new OutputLengthException("output buffer too short"); } /* Loop through the input bytes */ for (int i = 0; i < len; i++) { out[i + outOff] = returnByte(in[i + inOff]); } return len; } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianRabbitEngine.java | 159 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianZuc128Engine.java | 228 |
public int processBytes(final byte[] in, final int inOff, final int len, final byte[] out, final int outOff) { /* Check for errors */ if (theResetState == null) { throw new IllegalStateException(getAlgorithmName() + " not initialised"); } if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + len) > out.length) { throw new OutputLengthException("output buffer too short"); } /* Loop through the input bytes */ for (int i = 0; i < len; i++) { out[i + outOff] = returnByte(in[i + inOff]); } return len; } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSkeinXofEngine.java | 126 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianZuc128Engine.java | 228 |
public int processBytes(final byte[] in, final int inOff, final int len, final byte[] out, final int outOff) { /* Check for errors */ if (theResetState == null) { throw new IllegalStateException(getAlgorithmName() + " not initialised"); } if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + len) > out.length) { throw new OutputLengthException("output buffer too short"); } /* Loop through the input bytes */ for (int i = 0; i < len; i++) { out[i + outOff] = returnByte(in[i + inOff]); } return len; } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSnow3GEngine.java | 204 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianZuc128Engine.java | 228 |
public int processBytes(final byte[] in, final int inOff, final int len, final byte[] out, final int outOff) { /* Check for errors */ if (theResetState == null) { throw new IllegalStateException(getAlgorithmName() + " not initialised"); } if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + len) > out.length) { throw new OutputLengthException("output buffer too short"); } /* Loop through the input bytes */ for (int i = 0; i < len; i++) { out[i + outOff] = returnByte(in[i + inOff]); } return len; } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 112 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianZuc128Engine.java | 228 |
public int processBytes(final byte[] in, final int inOff, final int len, final byte[] out, final int outOff) { /* Check for errors */ if (theResetState == null) { throw new IllegalStateException(getAlgorithmName() + " not initialised"); } if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + len) > out.length) { throw new OutputLengthException("output buffer too short"); } /* Loop through the input bytes */ for (int i = 0; i < len; i++) { out[i + outOff] = returnByte(in[i + inOff]); } return len; } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\jca\JcaSignature.java | 399 |
net\sourceforge\joceanus\gordianknot\impl\jca\JcaSignature.java | 674 |
JcaSLHDSASignature(final GordianCoreFactory pFactory, final GordianSignatureSpec pSignatureSpec) throws GordianException { /* Initialise class */ super(pFactory, pSignatureSpec); } @Override public void initForSigning(final GordianKeyPair pKeyPair) throws GordianException { /* Determine the required signer */ JcaKeyPair.checkKeyPair(pKeyPair); final String mySignName = getAlgorithmForKeyPair(pKeyPair); setSigner(JcaSignatureFactory.getJavaSignature(mySignName, false)); /* pass on call */ super.initForSigning(pKeyPair); } @Override public void initForVerify(final GordianKeyPair pKeyPair) throws GordianException { /* Determine the required signer */ JcaKeyPair.checkKeyPair(pKeyPair); final String mySignName = getAlgorithmForKeyPair(pKeyPair); setSigner(JcaSignatureFactory.getJavaSignature(mySignName, false)); /* pass on call */ super.initForVerify(pKeyPair); } /** * Obtain algorithmName for keyPair. * @param pKeyPair the keyPair * @return the name */ private static String getAlgorithmForKeyPair(final GordianKeyPair pKeyPair) { /* Build the algorithm */ final boolean isHash = pKeyPair.getKeyPairSpec().getSLHDSAKeySpec().isHash(); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianGroestlDigest.java | 72 |
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianJHDigest.java | 72 |
} @Override public int getDigestSize() { return theDigestLen; } @Override public void reset() { theDigest.reset(); } @Override public void update(final byte arg0) { final byte[] myByte = new byte[] { arg0 }; update(myByte, 0, 1); } @Override public void update(final byte[] pData, final int pOffset, final int pLength) { theDigest.update(pData, pOffset, ((long) pLength) * Byte.SIZE); } @Override public int getByteLength() { return theDigest.getBufferSize(); } @Override public GordianGroestlDigest copy() { |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSnow3GEngine.java | 150 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianZuc128Engine.java | 163 |
private GordianSnow3GEngine(final GordianSnow3GEngine pSource) { reset(pSource); } /** * initialise a Snow3G cipher. * @param forEncryption whether or not we are for encryption. * @param params the parameters required to set up the cipher. * @exception IllegalArgumentException if the params argument is inappropriate. */ public void init(final boolean forEncryption, final CipherParameters params) { /* * encryption and decryption is completely symmetrical, so the 'forEncryption' is * irrelevant. (Like 90% of stream ciphers) */ /* Determine parameters */ CipherParameters myParams = params; byte[] newKey = null; byte[] newIV = null; if ((myParams instanceof ParametersWithIV)) { final ParametersWithIV ivParams = (ParametersWithIV) myParams; newIV = ivParams.getIV(); myParams = ivParams.getParameters(); } if (myParams instanceof KeyParameter) { final KeyParameter keyParam = (KeyParameter) myParams; newKey = keyParam.getKey(); } /* Initialise engine and mark as initialised */ theIndex = 0; theIterations = 0; setKeyAndIV(newKey, newIV); /* Save reset state */ theResetState = copy(); } /** * Obtain Max iterations. * @return the maximum iterations */ protected int getMaxIterations() { return 625; |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 362 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 638 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 914 |
tt = w7 ^ w2 ^ w4 ^ w6 ^ (0x9E3779B9 ^ (4 + 3)); w7 = rotateLeft(tt, 11); r0 = w4; r1 = w5; r2 = w6; r3 = w7; r4 = r0; r0 &= r2; r0 ^= r3; r2 ^= r1; r2 ^= r0; r3 |= r4; r3 ^= r1; r4 ^= r2; r1 = r3; r3 |= r4; r3 ^= r0; r0 &= r1; r4 ^= r0; r1 ^= r3; r1 ^= r4; r4 = ~r4; serpent24SubKeys[i++] = r2; serpent24SubKeys[i++] = r3; serpent24SubKeys[i++] = r1; serpent24SubKeys[i++] = r4; tt = w0 ^ w3 ^ w5 ^ w7 ^ (0x9E3779B9 ^ (8)); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\macs\GordianBlake2Mac.java | 63 |
net\sourceforge\joceanus\gordianknot\impl\ext\macs\GordianBlake3Mac.java | 62 |
throw new IllegalArgumentException("Blake2Mac requires a key parameter."); } /* Configure the digest */ theDigest.init(myBlakeParams); } @Override public int getMacSize() { return theDigest.getDigestSize(); } @Override public void update(final byte in) { theDigest.update(in); } @Override public void update(final byte[] in, final int inOff, final int len) { theDigest.update(in, inOff, len); } @Override public int doFinal(final byte[] out, final int outOff) { return theDigest.doFinal(out, outOff); } @Override public void reset() { theDigest.reset(); } |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\jca\JcaAgreement.java | 434 |
net\sourceforge\joceanus\gordianknot\impl\jca\JcaAgreement.java | 539 |
theAgreement.doPhase(myTarget.getPublicKey(), true); storeSecret(theAgreement.generateSecret()); } catch (InvalidKeyException | InvalidAlgorithmParameterException e) { throw new GordianCryptoException(ERR_AGREEMENT, e); } } /** * Establish the agreement. * @param pKeyPair the keyPair * @throws GordianException on error */ private void establishAgreement(final GordianKeyPair pKeyPair) throws GordianException { if (getAgreementSpec().getKeyPairSpec().getKeyPairType().equals(GordianKeyPairType.XDH)) { final String myBase = pKeyPair.getKeyPairSpec().toString(); final String myName = JcaAgreementFactory.getFullAgreementName(myBase, getAgreementSpec()); theAgreement = JcaAgreementFactory.getJavaKeyAgreement(myName, false); } } } /** * Jca Signed Agreement. */ public static class JcaSignedAgreement |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyEdDSAKeyPair.java | 465 |
net\sourceforge\joceanus\gordianknot\impl\bc\BouncySM2KeyPair.java | 103 |
theSigner.init(false, myPublic.getPublicKey()); } @Override public void update(final byte[] pBytes, final int pOffset, final int pLength) { theSigner.update(pBytes, pOffset, pLength); } @Override public void update(final byte pByte) { theSigner.update(pByte); } @Override public void update(final byte[] pBytes) { theSigner.update(pBytes, 0, pBytes.length); } @Override public void reset() { theSigner.reset(); } @Override protected BouncyKeyPair getKeyPair() { return (BouncyKeyPair) super.getKeyPair(); } @Override public BouncyFactory getFactory() { |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyMLDSAKeyPair.java | 326 |
net\sourceforge\joceanus\gordianknot\impl\bc\BouncySM2KeyPair.java | 103 |
theSigner.init(false, myPublic.getPublicKey()); } @Override public void update(final byte[] pBytes, final int pOffset, final int pLength) { theSigner.update(pBytes, pOffset, pLength); } @Override public void update(final byte pByte) { theSigner.update(pByte); } @Override public void update(final byte[] pBytes) { theSigner.update(pBytes, 0, pBytes.length); } @Override public void reset() { theSigner.reset(); } @Override protected BouncyKeyPair getKeyPair() { return (BouncyKeyPair) super.getKeyPair(); } @Override public BouncyFactory getFactory() { |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\core\agree\GordianCoreAgreementFactory.java | 287 |
net\sourceforge\joceanus\gordianknot\impl\core\agree\GordianCoreAgreementFactory.java | 300 |
case GOST2012: myAgreements.addAll(listAllKDFs(pKeyPairSpec, GordianAgreementType.ANON)); myAgreements.addAll(listAllKDFs(pKeyPairSpec, GordianAgreementType.KEM)); myAgreements.addAll(listAllKDFs(pKeyPairSpec, GordianAgreementType.BASIC)); myAgreements.addAll(listAllKDFs(pKeyPairSpec, GordianAgreementType.SIGNED)); myAgreements.addAll(listAllKDFs(pKeyPairSpec, GordianAgreementType.UNIFIED)); myAgreements.addAll(listAllKDFs(pKeyPairSpec, GordianAgreementType.UNIFIED, Boolean.TRUE)); myAgreements.addAll(listAllKDFs(pKeyPairSpec, GordianAgreementType.MQV)); myAgreements.addAll(listAllKDFs(pKeyPairSpec, GordianAgreementType.MQV, Boolean.TRUE)); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianBlake2Tree.java | 162 |
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianSkeinTree.java | 181 |
} /** * Process data. * @param pIn the input buffer * @param pInOffSet the starting offset in the input buffer * @param pLen the length of data to process */ private void processData(final byte[] pIn, final int pInOffSet, final int pLen) { /* Cannot process further data once tree is built */ if (theStore.treeBuilt()) { throw new IllegalStateException("Tree has been built"); } /* Determine space in current block */ final int blkSize = getLeafLen(); final int mySpace = blkSize - theProcessed; /* If all data can be processed by the current leaf */ if (mySpace >= pLen) { /* Update and return */ theDigest.update(pIn, pInOffSet, pLen); theProcessed += pLen; return; } /* Process as much as possible into current leaf */ if (mySpace > 0) { theDigest.update(pIn, pInOffSet, mySpace); theProcessed += mySpace; } /* Loop while we have data remaining */ int myProcessed = mySpace; while (myProcessed < pLen) { /* If the current leaf is full */ if (theProcessed == blkSize) { /* Finalise the leaf and process the result */ theDigest.doFinal(theHash, 0); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianBlake2Tree.java | 398 |
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianSkeinTree.java | 475 |
return myResult.length; } /** * Calculate tree result. * @param pOut the output buffer * @param pOutOffset the offset into the output buffer * @return the number of bytes returned */ int calculateTree(final byte[] pOut, final int pOutOffset) { /* Check parameters */ if (pOut.length < pOutOffset + theResult.length) { throw new OutputLengthException("Insufficient output buffer"); } if (treeBuilt) { throw new IllegalStateException("tree already built"); } /* Access the only level */ SimpleVector myLevel = (SimpleVector) theHashes.lastElement(); /* While we have elements that must be reduced */ while (myLevel.size() > 1) { /* Calculate the next set of hashes */ myLevel = calculateNextLevel(myLevel); theHashes.addElement(myLevel); } /* Note that the tree has been built */ treeBuilt = true; /* Return the final hash */ return obtainResult(pOut, pOutOffset); } /** * Calculate next level. * @param pInput the current set of hashes * @return the next level */ private SimpleVector calculateNextLevel(final SimpleVector pInput) { /* Set the depth of the tree */ final int myCurDepth = theHashes.size(); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\jca\JcaAEADCipher.java | 68 |
net\sourceforge\joceanus\gordianknot\impl\jca\JcaCipher.java | 69 |
JcaAEADCipher(final JcaFactory pFactory, final GordianCipherSpec<T> pCipherSpec, final Cipher pCipher) { super(pFactory, pCipherSpec); theCipher = pCipher; } @Override public JcaKey<T> getKey() { return (JcaKey<T>) super.getKey(); } @Override public void init(final boolean pEncrypt, final GordianCipherParameters pParams) throws GordianException { /* Process the parameters and access the key */ processParameters(pParams); final JcaKey<T> myJcaKey = JcaKey.accessKey(getKey()); /* Access details */ final int myMode = pEncrypt ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE; final SecretKey myKey = myJcaKey.getKey(); final byte[] myAEAD = getInitialAEAD(); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\jca\JcaAgreement.java | 320 |
net\sourceforge\joceanus\gordianknot\impl\jca\JcaAgreement.java | 434 |
net\sourceforge\joceanus\gordianknot\impl\jca\JcaAgreement.java | 539 |
theAgreement.doPhase(myPublic.getPublicKey(), true); storeSecret(theAgreement.generateSecret()); } catch (InvalidKeyException | InvalidAlgorithmParameterException e) { throw new GordianCryptoException(ERR_AGREEMENT, e); } } /** * Establish the agreement. * @param pKeyPair the keyPair * @throws GordianException on error */ private void establishAgreement(final GordianKeyPair pKeyPair) throws GordianException { if (getAgreementSpec().getKeyPairSpec().getKeyPairType().equals(GordianKeyPairType.XDH)) { final String myBase = pKeyPair.getKeyPairSpec().toString(); final String myName = JcaAgreementFactory.getFullAgreementName(myBase, getAgreementSpec()); theAgreement = JcaAgreementFactory.getJavaKeyAgreement(myName, false); } } } /** * Jca Basic Agreement. */ public static class JcaBasicAgreement |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianBlake2XEngine.java | 70 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSkeinXofEngine.java | 71 |
theKeyStream = new byte[theBlake2X.getByteLength() >> 1]; reset(pSource); } /** * initialise a Blake2X cipher. * @param forEncryption whether or not we are for encryption. * @param params the parameters required to set up the cipher. * @exception IllegalArgumentException if the params argument is inappropriate. */ public void init(final boolean forEncryption, final CipherParameters params) { /* * Blake2X encryption and decryption is completely symmetrical, so the 'forEncryption' is * irrelevant. (Like 90% of stream ciphers) */ /* Determine parameters */ CipherParameters myParams = params; byte[] newKey = null; byte[] newIV = null; if ((myParams instanceof ParametersWithIV)) { final ParametersWithIV ivParams = (ParametersWithIV) myParams; newIV = ivParams.getIV(); myParams = ivParams.getParameters(); } if (myParams instanceof KeyParameter) { final KeyParameter keyParam = (KeyParameter) myParams; newKey = keyParam.getKey(); } if (newKey == null || newIV == null) { throw new IllegalArgumentException("A key and IV must be provided"); } /* Initialise engine and mark as initialised */ final GordianBlake2ParametersBuilder myBuilder = new GordianBlake2ParametersBuilder() |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 603 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 1155 |
tt = w3 ^ w6 ^ w0 ^ w2 ^ (0x9E3779B9 ^ (32 + 3)); w3 = rotateLeft(tt, 11); r0 = w0; r1 = w1; r2 = w2; r3 = w3; r4 = r0; r0 |= r3; r3 ^= r1; r1 &= r4; r4 ^= r2; r2 ^= r3; r3 &= r0; r4 |= r1; r3 ^= r4; r0 ^= r1; r4 &= r0; r1 ^= r3; r4 ^= r2; r1 |= r0; r1 ^= r2; r0 ^= r3; r2 = r1; r1 |= r3; r1 ^= r0; serpent24SubKeys[i++] = r1; serpent24SubKeys[i++] = r2; serpent24SubKeys[i++] = r3; serpent24SubKeys[i++] = r4; |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyDSTUKeyPair.java | 198 |
net\sourceforge\joceanus\gordianknot\impl\bc\BouncyGOSTKeyPair.java | 203 |
final BCDSTU4145PublicKey pubKey = new BCDSTU4145PublicKey(ALGO, myParms, theSpec); return new X509EncodedKeySpec(pubKey.getEncoded()); } @Override public BouncyKeyPair derivePublicOnlyKeyPair(final X509EncodedKeySpec pEncodedKey) throws GordianException { final BouncyECPublicKey myPublic = derivePublicKey(pEncodedKey); return new BouncyKeyPair(myPublic); } /** * Derive public key from encoded. * @param pEncodedKey the encoded key * @return the public key * @throws GordianException on error */ private BouncyECPublicKey derivePublicKey(final X509EncodedKeySpec pEncodedKey) throws GordianException { /* Check the keySpecs */ checkKeySpec(pEncodedKey); /* derive publicKey */ final SubjectPublicKeyInfo myInfo = SubjectPublicKeyInfo.getInstance(pEncodedKey.getEncoded()); final ECPublicKeyParameters myParms = deriveFromPubKeyInfo(myInfo); return new BouncyECPublicKey(getKeySpec(), myParms); } /** * Derive Public Key parameters from SubjectPublicKeyInfo. (extracted from BouncyCastle initialiser) * @param pKeyInfo the keyInfo * @return the PrivateKeyParameters * @throws GordianException on error */ private ECPublicKeyParameters deriveFromPubKeyInfo(final SubjectPublicKeyInfo pKeyInfo) throws GordianException { final ASN1BitString bits = pKeyInfo.getPublicKeyData(); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianZuc128Engine.java | 319 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianZuc128Engine.java | 355 |
private void lfsrWithInitialisationMode(final int u) { int f = lfsrState[0]; int v = mulByPow2(lfsrState[0], 8); f = addM(f, v); v = mulByPow2(lfsrState[4], 20); f = addM(f, v); v = mulByPow2(lfsrState[10], 21); f = addM(f, v); v = mulByPow2(lfsrState[13], 17); f = addM(f, v); v = mulByPow2(lfsrState[15], 15); f = addM(f, v); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianBlake2XEngine.java | 71 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianBlake3Engine.java | 68 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSkeinXofEngine.java | 72 |
reset(pSource); } /** * initialise a Blake2X cipher. * @param forEncryption whether or not we are for encryption. * @param params the parameters required to set up the cipher. * @exception IllegalArgumentException if the params argument is inappropriate. */ public void init(final boolean forEncryption, final CipherParameters params) { /* * Blake2X encryption and decryption is completely symmetrical, so the 'forEncryption' is * irrelevant. (Like 90% of stream ciphers) */ /* Determine parameters */ CipherParameters myParams = params; byte[] newKey = null; byte[] newIV = null; if ((myParams instanceof ParametersWithIV)) { final ParametersWithIV ivParams = (ParametersWithIV) myParams; newIV = ivParams.getIV(); myParams = ivParams.getParameters(); } if (myParams instanceof KeyParameter) { final KeyParameter keyParam = (KeyParameter) myParams; newKey = keyParam.getKey(); } if (newKey == null || newIV == null) { throw new IllegalArgumentException("A key and IV must be provided"); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianRabbitEngine.java | 112 |
net\sourceforge\joceanus\gordianknot\impl\ext\engines\GordianSosemanukEngine.java | 65 |
private GordianRabbitEngine(final GordianRabbitEngine pSource) { reset(pSource); } /** * initialise a Rabbit cipher. * @param forEncryption whether or not we are for encryption. * @param params the parameters required to set up the cipher. * @exception IllegalArgumentException if the params argument is inappropriate. */ public void init(final boolean forEncryption, final CipherParameters params) { /* * encryption and decryption is completely symmetrical, so the 'forEncryption' is * irrelevant. (Like 90% of stream ciphers) */ /* Determine parameters */ CipherParameters myParams = params; byte[] newKey = null; byte[] newIV = null; if ((myParams instanceof ParametersWithIV)) { final ParametersWithIV ivParams = (ParametersWithIV) myParams; newIV = ivParams.getIV(); myParams = ivParams.getParameters(); } if (myParams instanceof KeyParameter) { final KeyParameter keyParam = (KeyParameter) myParams; newKey = keyParam.getKey(); } /* Initialise engine and mark as initialised */ theIndex = 0; setKey(newKey); setIV(newIV); |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\core\cipher\GordianCoreCipherParameters.java | 334 |
net\sourceforge\joceanus\gordianknot\impl\core\cipher\GordianCoreCipherParameters.java | 365 |
myPassword = PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(pPassword); myGenerator.init(myPassword, thePBESalt, mySpec.getIterationCount()); /* Generate the parameters */ final int myKeyLen = theSpec.getKeyType().getKeyLength().getLength(); final int myIVLen = theSpec.needsIV() ? Byte.SIZE * theSpec.getIVLength() : 0; return myIVLen == 0 ? myGenerator.generateDerivedParameters(myKeyLen) : myGenerator.generateDerivedParameters(myKeyLen, myIVLen); } finally { if (myPassword != null) { Arrays.fill(myPassword, (byte) 0); } } } /** * derive PKCS12 key and IV. * @param pPassword the password * @return the parameters */ private CipherParameters derivePKCS12Parameters(final char[] pPassword) { |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianBlake2bDigest.java | 149 |
net\sourceforge\joceanus\gordianknot\impl\ext\digests\GordianBlake2sDigest.java | 149 |
return new GordianBlake2bDigest(this); } @Override void adjustCounter(final int pCount) { t0 += pCount; if (t0 == 0) { t1++; } } @Override void completeCounter(final int pCount) { t0 += pCount; if (pCount > 0 && t0 == 0) { t1++; } } @Override void outputDigest(final byte[] pOut, final int pOutOffset) { /* Loop to provide the output */ final int myDigestLen = getDigestSize(); for (int i = 0, j = 0; i < NUMWORDS && j < myDigestLen; i++, j += Long.BYTES) { |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\core\agree\GordianCompositeAgreement.java | 391 |
net\sourceforge\joceanus\gordianknot\impl\core\agree\GordianCompositeAgreement.java | 662 |
GordianCompositeBasicAgreement(final GordianCoreFactory pFactory, final GordianAgreementSpec pSpec) throws GordianException { /* Initialise super class */ super(pFactory, pSpec); /* Create the list */ theAgreements = new ArrayList<>(); final GordianAgreementFactory myFactory = pFactory.getKeyPairFactory().getAgreementFactory(); final List<GordianAgreementSpec> mySubAgrees = getSubAgreements(pSpec); for (GordianAgreementSpec mySpec : mySubAgrees) { theAgreements.add(myFactory.createAgreement(mySpec)); } } @Override public GordianAgreementMessageASN1 createClientHelloASN1(final GordianKeyPair pClient) throws GordianException { /* Check keyPair */ checkKeyPair(pClient); /* Create ephemeral key */ final GordianKeyPairFactory myFactory = getFactory().getKeyPairFactory(); final GordianCompositeKeyPair myClient = (GordianCompositeKeyPair) pClient; |
File | Line |
---|---|
net\sourceforge\joceanus\gordianknot\impl\core\agree\GordianCoreBasicAgreement.java | 76 |
net\sourceforge\joceanus\gordianknot\impl\core\agree\GordianCoreEphemeralAgreement.java | 246 |
final GordianAgreementMessageASN1 myClientHello = buildClientHelloASN1(); /* Set status */ setStatus(GordianAgreementStatus.AWAITING_SERVERHELLO); /* Return the clientHello */ return myClientHello; } @Override public byte[] acceptClientHello(final GordianKeyPair pClient, final GordianKeyPair pServer, final byte[] pClientHello) throws GordianException { /* Must be in clean state */ checkStatus(GordianAgreementStatus.CLEAN); /* Access the sequence */ final GordianAgreementMessageASN1 myClientHello = GordianAgreementMessageASN1.getInstance(pClientHello); myClientHello.checkMessageType(GordianMessageType.CLIENTHELLO); /* Accept the ASN1 */ final GordianAgreementMessageASN1 myServerHello = acceptClientHelloASN1(pClient, pServer, myClientHello); return myServerHello.getEncodedBytes(); } /** * Accept the clientHello. * @param pClient the client keyPair * @param pServer the server keyPair * @param pClientHello the incoming clientHello message * @return the serverHello message * @throws GordianException on error */ public abstract GordianAgreementMessageASN1 acceptClientHelloASN1(GordianKeyPair pClient, GordianKeyPair pServer, GordianAgreementMessageASN1 pClientHello) throws GordianException; /** * Process the incoming clientHello message request. * @param pServer the server keyPair * @param pClientHello the incoming clientHello message * @throws GordianException on error */ protected void processClientHelloASN1(final GordianKeyPair pServer, |