Exemplo n.º 1
0
  public SignerInfo(ASN1Sequence seq) {
    Enumeration e = seq.getObjects();

    version = (ASN1Integer) e.nextElement();
    sid = SignerIdentifier.getInstance(e.nextElement());
    digAlgorithm = AlgorithmIdentifier.getInstance(e.nextElement());

    Object obj = e.nextElement();

    if (obj instanceof ASN1TaggedObject) {
      authenticatedAttributes = ASN1Set.getInstance((ASN1TaggedObject) obj, false);

      digEncryptionAlgorithm = AlgorithmIdentifier.getInstance(e.nextElement());
    } else {
      authenticatedAttributes = null;
      digEncryptionAlgorithm = AlgorithmIdentifier.getInstance(obj);
    }

    encryptedDigest = DEROctetString.getInstance(e.nextElement());

    if (e.hasMoreElements()) {
      unauthenticatedAttributes = ASN1Set.getInstance((ASN1TaggedObject) e.nextElement(), false);
    } else {
      unauthenticatedAttributes = null;
    }
  }
Exemplo n.º 2
0
  private BasicOCSPResponse(ASN1Sequence seq) {
    this.tbsResponseData = ResponseData.getInstance(seq.getObjectAt(0));
    this.signatureAlgorithm = AlgorithmIdentifier.getInstance(seq.getObjectAt(1));
    this.signature = (DERBitString) seq.getObjectAt(2);

    if (seq.size() > 3) {
      this.certs = ASN1Sequence.getInstance((ASN1TaggedObject) seq.getObjectAt(3), true);
    }
  }
Exemplo n.º 3
0
  private OOBCertHash(ASN1Sequence seq) {
    int index = seq.size() - 1;

    hashVal = DERBitString.getInstance(seq.getObjectAt(index--));

    for (int i = index; i >= 0; i--) {
      ASN1TaggedObject tObj = (ASN1TaggedObject) seq.getObjectAt(i);

      if (tObj.getTagNo() == 0) {
        hashAlg = AlgorithmIdentifier.getInstance(tObj, true);
      } else {
        certId = CertId.getInstance(tObj, true);
      }
    }
  }
  public GenericKey generateUnwrappedKey(
      AlgorithmIdentifier encryptedKeyAlgorithm, byte[] encryptedKey) throws OperatorException {
    try {
      Cipher keyCipher =
          helper.createSymmetricWrapper(this.getAlgorithmIdentifier().getAlgorithm());

      keyCipher.init(Cipher.UNWRAP_MODE, secretKey);

      return new JceGenericKey(
          encryptedKeyAlgorithm,
          keyCipher.unwrap(
              encryptedKey,
              helper.getKeyAlgorithmName(encryptedKeyAlgorithm.getAlgorithm()),
              Cipher.SECRET_KEY));
    } catch (InvalidKeyException e) {
      throw new OperatorException("key invalid in message.", e);
    } catch (NoSuchAlgorithmException e) {
      throw new OperatorException("can't find algorithm.", e);
    }
  }