List of usage examples for org.bouncycastle.crypto CryptoException CryptoException
public CryptoException()
From source file:com.distrimind.util.crypto.EllipticCurveDiffieHellmanAlgorithm.java
License:Open Source License
@Override protected byte[] getDataToSend(int stepNumber) throws Exception { if (!valid)/*from w w w . j a va2 s . co m*/ throw new CryptoException(); if (stepNumber == 0) return getEncodedPublicKey(); else { valid = false; throw new IllegalAccessException(); } }
From source file:com.distrimind.util.crypto.EllipticCurveDiffieHellmanAlgorithm.java
License:Open Source License
@Override protected void receiveData(int stepNumber, byte[] data) throws CryptoException { if (!valid)/*from w w w .jav a2 s .co m*/ throw new CryptoException(); try { if (stepNumber == 0) { setDistantPublicKey(data, encryptionType, signatureType, keyingMaterial); } else throw new IllegalAccessException(); } catch (Exception e) { valid = false; throw new CryptoException("", e); } }
From source file:com.distrimind.util.crypto.NewHopeKeyAgreementClient.java
License:Open Source License
@Override protected byte[] getDataToSend(int stepNumber) throws Exception { if (!valid)/* w w w. j ava 2s .co m*/ throw new CryptoException(); try { if (stepNumber == 0) return getDataPhase1(); else { valid = false; throw new IllegalAccessException(); } } catch (Exception e) { valid = false; throw e; } }
From source file:com.distrimind.util.crypto.NewHopeKeyAgreementClient.java
License:Open Source License
@Override protected void receiveData(int stepNumber, byte[] data) throws CryptoException { if (!valid)//from w w w . j a va 2s. c o m throw new CryptoException(); try { if (stepNumber == 0) setDataPhase2(data); else throw new IllegalAccessException(); } catch (Exception e) { valid = false; throw new CryptoException("", e); } }
From source file:com.distrimind.util.crypto.NewHopeKeyAgreementServer.java
License:Open Source License
@Override protected byte[] getDataToSend(int stepNumber) throws Exception { if (!valid)//from www .ja va 2 s . c om throw new CryptoException(); try { if (stepNumber == 0) return getDataPhase2(); else { valid = false; throw new IllegalAccessException(); } } catch (Exception e) { valid = false; throw e; } }
From source file:com.distrimind.util.crypto.NewHopeKeyAgreementServer.java
License:Open Source License
@Override protected void receiveData(int stepNumber, byte[] data) throws CryptoException { if (!valid)//from w w w . j a v a2s. c om throw new CryptoException(); try { if (stepNumber == 0) setDataPhase1(data); else throw new IllegalAccessException(); } catch (Exception e) { valid = false; throw new CryptoException("", e); } }
From source file:com.distrimind.util.crypto.P2PLoginCheckerWithASymmetricSignature.java
License:Open Source License
@Override protected byte[] getDataToSend(int stepNumber) throws CryptoException { if (!valid)//from www .j a va 2 s. co m throw new CryptoException(); switch (stepNumber) { case 0: return myMessage; case 1: return emptyTab; default: valid = false; throw new IllegalAccessError(); } }
From source file:com.distrimind.util.crypto.P2PLoginCheckerWithASymmetricSignature.java
License:Open Source License
@Override protected void receiveData(int stepNumber, byte[] data) throws CryptoException { if (!valid)// ww w .j a v a2 s . co m throw new CryptoException(); try { switch (stepNumber) { case 0: { if (data.length != P2PLoginWithASymmetricSignature.messageSize) { valid = false; throw new CryptoException(); } otherMessage = data; } break; case 1: { if (otherMessage == null) { valid = false; throw new CryptoException(); } ASymmetricAuthenticatedSignatureCheckerAlgorithm checker = new ASymmetricAuthenticatedSignatureCheckerAlgorithm( publicKey); checker.init(data); checker.update(otherMessage); checker.update(myMessage); valid = checker.verify(); } break; default: valid = false; throw new CryptoException("" + stepNumber); } } catch (Exception e) { valid = false; if (e instanceof CryptoException) throw (CryptoException) e; else throw new CryptoException("", e); } }
From source file:com.distrimind.util.crypto.P2PLoginWithASymmetricSignature.java
License:Open Source License
@Override protected byte[] getDataToSend(int stepNumber) throws Exception { if (!valid)/* w ww . jav a2 s .c o m*/ throw new CryptoException(); try { switch (stepNumber) { case 0: return myMessage; case 1: { if (otherMessage == null) { valid = false; throw new IllegalAccessError(); } ASymmetricAuthenticatedSignerAlgorithm signer = new ASymmetricAuthenticatedSignerAlgorithm( privateKey); signer.init(); signer.update(myMessage); signer.update(otherMessage); return signer.getSignature(); } default: valid = false; throw new IllegalAccessError(); } } catch (Exception e) { valid = false; throw e; } }
From source file:com.distrimind.util.crypto.P2PLoginWithASymmetricSignature.java
License:Open Source License
@Override protected void receiveData(int stepNumber, byte[] data) throws CryptoException { if (!valid)/* ww w .jav a 2 s .c o m*/ throw new CryptoException(); switch (stepNumber) { case 0: { if (otherMessage != null) { valid = false; throw new CryptoException(); } if (data.length != messageSize) { valid = false; throw new CryptoException(); } otherMessage = data; } break; case 1: { if (data.length != 0) { valid = false; throw new CryptoException(); } } break; default: valid = false; throw new CryptoException("" + stepNumber); } }