示例#1
0
        /**
         * Create a buffered block cipher without padding.
         *
         * @param cipher the underlying block cipher this buffering object wraps.
         * @param padded true if the buffer should add, or remove, pad bytes,
         * false otherwise.
         */
        public BufferedBlockCipher(
            BlockCipher cipher)
        {
            this.cipher = cipher;

            buf    = new byte[cipher.getBlockSize()];
            bufOff = 0;

            //
            // check if we can handle partial blocks on doFinal.
            //
            String name = cipher.getAlgorithmName();
            int    idx  = name.IndexOf('/') + 1;

            pgpCFB = (idx > 0 && name.Substring(idx).StartsWith("PGP"));

            if (pgpCFB)
            {
                partialBlockOkay = true;
            }
            else
            {
                partialBlockOkay = (idx > 0 && (name.Substring(idx).StartsWith("CFB") ||
                                                name.Substring(idx).StartsWith("OFB")));
            }
        }
示例#2
0
 /**
  * return the algorithm name and mode.
  *
  * @return the name of the underlying algorithm followed by "/CBC".
  */
 public String getAlgorithmName()
 {
     return(cipher.getAlgorithmName() + "/CBC");
 }
示例#3
0
 /**
  * return the algorithm name and mode.
  *
  * @return the name of the underlying algorithm followed by "/CFB"
  * and the block size in bits.
  */
 public String getAlgorithmName()
 {
     return(cipher.getAlgorithmName() + "/CFB" + (blockSize * 8));
 }