/**
  * @param factory The {@link org.apache.sshd.common.NamedFactory} for the signature - ignored if
  *     {@code null}
  * @return The matching {@link org.apache.sshd.common.signature.BuiltinSignatures} whose factory
  *     name matches (case <U>insensitive</U>) the digest factory name
  * @see #fromFactoryName(String)
  */
 public static BuiltinSignatures fromFactory(NamedFactory<Signature> factory) {
   if (factory == null) {
     return null;
   } else {
     return fromFactoryName(factory.getName());
   }
 }
Exemple #2
0
  private static void loadTest(NamedFactory<Cipher> factory, Random random, int numRounds)
      throws Exception {
    Cipher cipher = factory.create();
    byte[] key = new byte[cipher.getBlockSize()];
    byte[] iv = new byte[cipher.getIVSize()];
    random.fill(key, 0, key.length);
    random.fill(iv, 0, iv.length);
    cipher.init(Cipher.Mode.Encrypt, key, iv);

    byte[] input = new byte[BufferUtils.getNextPowerOf2(key.length)];
    random.fill(input, 0, input.length);
    long t0 = System.currentTimeMillis();
    for (int i = 0; i < numRounds; i++) {
      cipher.update(input, 0, input.length);
    }
    long t1 = System.currentTimeMillis();
    System.err.println(factory.getName() + "[" + numRounds + "]: " + (t1 - t0) + " ms");
  }