code: private static byte[] emsa_encode(SignatureParamSpec spec, byte[] msg, int emLen) {
          byte[] H = hash(spec, msg);
          byte[] T = createDigestInfo(spec, H);
          int tLen = T.length;
  
          byte[] PS = new byte[emLen - tLen - 3];
          Arrays.fill(PS, (byte) 0xFF);
  
          ByteArrayOutputStream EMs = new ByteArrayOutputStream();
          try {
              EMs.write(0x00);
              EMs.write(0x01);
              EMs.write(PS);
              EMs.write(0x00);
              EMs.write(T);
          } catch (IOException e) {
              throw new RuntimeException(e);
          }
          byte[] EM = EMs.toByteArray();
  
          return EM;
      }
docs: --------------------------------------------------------------------