private void desCbcDecrypt(WrapToken token,byte[] key,byte[] cipherText,int offset,int len,byte[] dataOutBuf,int dataOffset) throws GSSException {
  try {
    int temp=0;
    Cipher des=getInitializedDes(false,key,ZERO_IV);
    temp=des.update(cipherText,offset,WrapToken.CONFOUNDER_SIZE,token.confounder);
    offset+=WrapToken.CONFOUNDER_SIZE;
    len-=WrapToken.CONFOUNDER_SIZE;
    int blockSize=des.getBlockSize();
    int numBlocks=len / blockSize - 1;
    for (int i=0; i < numBlocks; i++) {
      temp=des.update(cipherText,offset,blockSize,dataOutBuf,dataOffset);
      offset+=blockSize;
      dataOffset+=blockSize;
    }
    byte[] finalBlock=new byte[blockSize];
    des.update(cipherText,offset,blockSize,finalBlock);
    des.doFinal();
    int padSize=finalBlock[blockSize - 1];
    if (padSize < 1 || padSize > 8)     throw new GSSException(GSSException.DEFECTIVE_TOKEN,-1,"Invalid padding on Wrap Token");
    token.padding=WrapToken.pads[padSize];
    blockSize-=padSize;
    System.arraycopy(finalBlock,0,dataOutBuf,dataOffset,blockSize);
  }
 catch (  GeneralSecurityException e) {
    GSSException ge=new GSSException(GSSException.FAILURE,-1,"Could not use DES cipher - " + e.getMessage());
    ge.initCause(e);
    throw ge;
  }
}

private void desCbcDecrypt ( WrapToken token , byte [ ] key , byte [ ] cipherText , int offset , int len , byte [ ] dataOutBuf , int dataOffset ) throws GSSException { try { int temp = 0 ; Cipher des = getInitializedDes ( false , key , ZERO_IV ) ; temp = des . update ( cipherText , offset , WrapToken . CONFOUNDER_SIZE , token . confounder ) ; offset += WrapToken . CONFOUNDER_SIZE ; len -= WrapToken . CONFOUNDER_SIZE ; int blockSize = des . getBlockSize ( ) ; int numBlocks = len / blockSize - 1 ; for ( int i = 0 ; i < numBlocks ; i ++ ) { temp = des . update ( cipherText , offset , blockSize , dataOutBuf , dataOffset ) ; offset += blockSize ; dataOffset += blockSize ; } byte [ ] finalBlock = new byte [ blockSize ] ; des . update ( cipherText , offset , blockSize , finalBlock ) ; des . doFinal ( ) ; int padSize = finalBlock [ blockSize - 1 ] ; if ( padSize < 1 || padSize > 8 ) throw new GSSException ( GSSException . DEFECTIVE_TOKEN , - 1 , "Invalid padding on Wrap Token" ) ; token . padding = WrapToken . pads [ padSize ] ; blockSize -= padSize ; System . arraycopy ( finalBlock , 0 , dataOutBuf , dataOffset , blockSize ) ; } catch ( GeneralSecurityException e ) { GSSException ge = new GSSException ( GSSException . FAILURE , - 1 , "Could not use DES cipher - " + e . getMessage ( ) ) ; ge . initCause ( e ) ; throw ge ; } }
helper routine to decrypt fromm a byte array and write the application data straight to an output array with minimal buffer copies . the confounder and the padding are stored separately and not copied into this output array .
