private byte[] padV15(byte[] data) throws BadPaddingException {
  byte[] padded=new byte[paddedSize];
  System.arraycopy(data,0,padded,paddedSize - data.length,data.length);
  int psSize=paddedSize - 3 - data.length;
  int k=0;
  padded[k++]=0;
  padded[k++]=(byte)type;
  if (type == PAD_BLOCKTYPE_1) {
    while (psSize-- > 0) {
      padded[k++]=(byte)0xff;
    }
  }
 else {
    if (random == null) {
      random=JCAUtil.getSecureRandom();
    }
    byte[] r=new byte[64];
    int i=-1;
    while (psSize-- > 0) {
      int b;
      do {
        if (i < 0) {
          random.nextBytes(r);
          i=r.length - 1;
        }
        b=r[i--] & 0xff;
      }
 while (b == 0);
      padded[k++]=(byte)b;
    }
  }
  return padded;
}

private byte [ ] padV15 ( byte [ ] data ) throws BadPaddingException { byte [ ] padded = new byte [ paddedSize ] ; System . arraycopy ( data , 0 , padded , paddedSize - data . length , data . length ) ; int psSize = paddedSize - 3 - data . length ; int k = 0 ; padded [ k ++ ] = 0 ; padded [ k ++ ] = ( byte ) type ; if ( type == PAD_BLOCKTYPE_1 ) { while ( psSize -- > 0 ) { padded [ k ++ ] = ( byte ) 0xff ; } } else { if ( random == null ) { random = JCAUtil . getSecureRandom ( ) ; } byte [ ] r = new byte [ 64 ] ; int i = - 1 ; while ( psSize -- > 0 ) { int b ; do { if ( i < 0 ) { random . nextBytes ( r ) ; i = r . length - 1 ; } b = r [ i -- ] & 0xff ; } while ( b == 0 ) ; padded [ k ++ ] = ( byte ) b ; } } return padded ; }
pkcs # 1 v1 . 5 padding ( blocktype 1 and 2 ) .
