Esempio n. 1
0
 // this takes a buffer of information and fills the block
 private void processFilledBuffer(byte[] in, int inOff) {
   // copies into the block...
   for (int i = 0; i < _state.length; i++) {
     _block[i] = bytesToLongFromBuffer(_buffer, i * 8);
   }
   processBlock();
   _bufferPos = 0;
   Arrays.fill(_buffer, (byte) 0);
 }
Esempio n. 2
0
 /** reset the chaining variables */
 public void reset() {
   // set variables to null, blank, whatever
   _bufferPos = 0;
   Arrays.fill(_bitCount, (short) 0);
   Arrays.fill(_buffer, (byte) 0);
   Arrays.fill(_hash, 0);
   Arrays.fill(_K, 0);
   Arrays.fill(_L, 0);
   Arrays.fill(_block, 0);
   Arrays.fill(_state, 0);
 }
Esempio n. 3
0
  public byte[] unwrap(byte[] in, int inOff, int inLen) throws InvalidCipherTextException {
    if (forWrapping) {
      throw new IllegalStateException("not set for unwrapping");
    }

    int n = inLen / 8;

    if ((n * 8) != inLen) {
      throw new InvalidCipherTextException("unwrap data must be a multiple of 8 bytes");
    }

    byte[] block = new byte[inLen - iv.length];
    byte[] a = new byte[iv.length];
    byte[] buf = new byte[8 + iv.length];

    System.arraycopy(in, 0, a, 0, iv.length);
    System.arraycopy(in, iv.length, block, 0, inLen - iv.length);

    engine.init(false, param);

    n = n - 1;

    for (int j = 5; j >= 0; j--) {
      for (int i = n; i >= 1; i--) {
        System.arraycopy(a, 0, buf, 0, iv.length);
        System.arraycopy(block, 8 * (i - 1), buf, iv.length, 8);

        int t = n * j + i;
        for (int k = 1; t != 0; k++) {
          byte v = (byte) t;

          buf[iv.length - k] ^= v;

          t >>>= 8;
        }

        engine.processBlock(buf, 0, buf, 0);
        System.arraycopy(buf, 0, a, 0, 8);
        System.arraycopy(buf, 8, block, 8 * (i - 1), 8);
      }
    }

    if (!Arrays.constantTimeAreEqual(a, iv)) {
      throw new InvalidCipherTextException("checksum failed");
    }

    return block;
  }
Esempio n. 4
0
 public SRPTlsClient(TlsCipherFactory cipherFactory, byte[] identity, byte[] password) {
   this.cipherFactory = cipherFactory;
   this.identity = Arrays.clone(identity);
   this.password = Arrays.clone(password);
 }