Exemple #1
0
  /**
   * @param digest ObjectIdentifier
   * @param encryption ObjectIdentifier
   * @return String <digest>with<encryption>
   */
  public static String getSigningAlgorithm(ObjectIdentifier digest, ObjectIdentifier encryption) {
    StringBuffer sb = new StringBuffer();

    if (digest.equals(SHA1)) {
      sb.append("SHA1");
    } else if (digest.equals(SHA256)) {
      sb.append("SHA256");
    } else if (digest.equals(SHA384)) {
      sb.append("SHA384");
    }

    sb.append("with");

    if (encryption.equals(RSA)
        || encryption.equals(SHA1withRSA)
        || encryption.equals(SHA256withRSA)) {
      sb.append("RSA");
    } else if (encryption.equals(SHA256withRSAPSS)) {
      sb.append("RSAandMGF1");
    } else if (encryption.equals(ECDSA)
        || encryption.equals(SHA256withECDSA)
        || encryption.equals(SHA384withECDSA)) {
      sb.append("ECDSA");
    }
    if (debug) {
      System.out.println("Constructed SigAlg Name: " + sb.toString());
    }
    return sb.toString();
  }
Exemple #2
0
 /**
  * Method getSigningAlgorithm.
  *
  * @param sigalg ObjectIdentifier
  * @return String
  * @throws NoSuchAlgorithmException
  */
 public static String getSigningAlgorithm(ObjectIdentifier sigalg)
     throws NoSuchAlgorithmException {
   if (sigalg.equals(SHA1withRSA)) {
     return "SHA1withRSA";
   } else if (sigalg.equals(SHA256withRSA)) {
     return "SHA256withRSA";
   } else if (sigalg.equals(SHA256withECDSA)) {
     return "SHA256withECDSA";
   } else if (sigalg.equals(SHA384withECDSA)) {
     return "SHA384withECDSA";
   } else {
     throw new NoSuchAlgorithmException("Algorithm not included in NIST 800-78");
   }
 }