public byte[] generateSignature() throws CryptoException {
  int digSize=digest.getDigestSize();
  int t=0;
  int delta=0;
  if (trailer == TRAILER_IMPLICIT) {
    t=8;
    delta=block.length - digSize - 1;
    digest.doFinal(block,delta);
    block[block.length - 1]=(byte)TRAILER_IMPLICIT;
  }
 else {
    t=16;
    delta=block.length - digSize - 2;
    digest.doFinal(block,delta);
    block[block.length - 2]=(byte)(trailer >>> 8);
    block[block.length - 1]=(byte)trailer;
  }
  byte header=0;
  int x=(digSize + messageLength) * 8 + t + 4 - keyBits;
  if (x > 0) {
    int mR=messageLength - ((x + 7) / 8);
    header=0x60;
    delta-=mR;
    System.arraycopy(mBuf,0,block,delta,mR);
  }
 else {
    header=0x40;
    delta-=messageLength;
    System.arraycopy(mBuf,0,block,delta,messageLength);
  }
  if ((delta - 1) > 0) {
    for (int i=delta - 1; i != 0; i--) {
      block[i]=(byte)0xbb;
    }
    block[delta - 1]^=(byte)0x01;
    block[0]=(byte)0x0b;
    block[0]|=header;
  }
 else {
    block[0]=(byte)0x0a;
    block[0]|=header;
  }
  byte[] b=cipher.processBlock(block,0,block.length);
  clearBlock(mBuf);
  clearBlock(block);
  return b;
}

public byte [ ] generateSignature ( ) throws CryptoException { int digSize = digest . getDigestSize ( ) ; int t = 0 ; int delta = 0 ; if ( trailer == TRAILER_IMPLICIT ) { t = 8 ; delta = block . length - digSize - 1 ; digest . doFinal ( block , delta ) ; block [ block . length - 1 ] = ( byte ) TRAILER_IMPLICIT ; } else { t = 16 ; delta = block . length - digSize - 2 ; digest . doFinal ( block , delta ) ; block [ block . length - 2 ] = ( byte ) ( trailer > > > 8 ) ; block [ block . length - 1 ] = ( byte ) trailer ; } byte header = 0 ; int x = ( digSize + messageLength ) * 8 + t + 4 - keyBits ; if ( x > 0 ) { int mR = messageLength - ( ( x + 7 ) / 8 ) ; header = 0x60 ; delta -= mR ; System . arraycopy ( mBuf , 0 , block , delta , mR ) ; } else { header = 0x40 ; delta -= messageLength ; System . arraycopy ( mBuf , 0 , block , delta , messageLength ) ; } if ( ( delta - 1 ) > 0 ) { for ( int i = delta - 1 ; i != 0 ; i -- ) { block [ i ] = ( byte ) 0xbb ; } block [ delta - 1 ] ^= ( byte ) 0x01 ; block [ 0 ] = ( byte ) 0x0b ; block [ 0 ] |= header ; } else { block [ 0 ] = ( byte ) 0x0a ; block [ 0 ] |= header ; } byte [ ] b = cipher . processBlock ( block , 0 , block . length ) ; clearBlock ( mBuf ) ; clearBlock ( block ) ; return b ; }
generate a signature for the loaded message using the key we were initialised with .
