Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bouncycastle.pqc.crypto.mceliece;
  
  
  
 // TODO should implement some interface?
 {
 
     private final Digest messDigest;
 
     private final MessageEncryptor mcElieceCCA2Cipher;
 
     private boolean forEncrypting;
 
 
     public McEliecePointchevalDigestCipher(MessageEncryptor mcElieceCCA2CipherDigest messDigest)
     {
         this. = mcElieceCCA2Cipher;
         this. = messDigest;
     }
 
 
     public void init(boolean forEncrypting,
                      CipherParameters param)
     {
 
         this. = forEncrypting;
         AsymmetricKeyParameter k;
 
         if (param instanceof ParametersWithRandom)
         {
             k = (AsymmetricKeyParameter)((ParametersWithRandom)param).getParameters();
         }
         else
         {
             k = (AsymmetricKeyParameter)param;
         }
 
         if (forEncrypting && k.isPrivate())
         {
             throw new IllegalArgumentException("Encrypting Requires Public Key.");
         }
 
         if (!forEncrypting && !k.isPrivate())
         {
             throw new IllegalArgumentException("Decrypting Requires Private Key.");
         }
 
         reset();
 
         .init(forEncryptingparam);
     }
 
 
     public byte[] messageEncrypt()
     {
         if (!)
         {
             throw new IllegalStateException("McEliecePointchevalDigestCipher not initialised for encrypting.");
         }
 
         byte[] hash = new byte[.getDigestSize()];
         .doFinal(hash, 0);
         byte[] enc = null;
 
         try
         {
             enc = .messageEncrypt(hash);
         }
         catch (Exception e)
         {
             e.printStackTrace();
         }
 
 
         return enc;
     }
 
 
     public byte[] messageDecrypt(byte[] ciphertext)
     {
         byte[] output = null;
         if ()
         {
             throw new IllegalStateException("McEliecePointchevalDigestCipher not initialised for decrypting.");
         }
 
 
         try
         {
             output = .messageDecrypt(ciphertext);
         }
         catch (Exception e)
         {
            e.printStackTrace();
        }
        return output;
    }
    public void update(byte b)
    {
        .update(b);
    }
    public void update(byte[] inint offint len)
    {
        .update(inofflen);
    }
    public void reset()
    {
        .reset();
    }
New to GrepCode? Check out our FAQ X