예제 #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();
  }
예제 #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");
   }
 }
예제 #3
0
 /**
  * Constructor for AlgorithmIdentifier.
  *
  * @param oid ObjectIdentifier
  * @param param AlgorithmParameters
  * @throws ASN1Exception
  */
 public AlgorithmIdentifier(ObjectIdentifier oid, AlgorithmParameters param) throws ASN1Exception {
   this.ident = ASN1Factory.encodeASN1Object(new Tag(Tag.OBJECTID), oid.getEncoded());
   this.ai.addComponent(this.ident);
   if (param == null) {
     try {
       this.param = new NULL();
     } catch (TLVEncodingException e) {
       throw new ASN1Exception(e);
     }
     this.ai.addComponent(this.param);
   }
 }