home *** CD-ROM | disk | FTP | other *** search
- package sun.security.pkcs;
-
- import java.io.IOException;
- import java.security.IdentityScope;
- import java.security.InvalidKeyException;
- import java.security.NoSuchAlgorithmException;
- import java.security.PublicKey;
- import java.security.Signature;
- import java.security.SignatureException;
- import sun.security.util.BigInt;
- import sun.security.util.DerInputStream;
- import sun.security.util.DerOutputStream;
- import sun.security.util.DerValue;
- import sun.security.x509.AlgorithmId;
- import sun.security.x509.X500Name;
- import sun.security.x509.X509Cert;
-
- public class SignerInfo {
- BigInt version;
- X500Name issuerName;
- BigInt certificateSerialNumber;
- AlgorithmId digestAlgorithmId;
- AlgorithmId digestEncryptionAlgorithmId;
- byte[] encryptedDigest;
-
- public SignerInfo(X500Name var1, BigInt var2, AlgorithmId var3, AlgorithmId var4, byte[] var5) {
- this.version = new BigInt(1);
- this.issuerName = var1;
- this.certificateSerialNumber = var2;
- this.digestAlgorithmId = var3;
- this.digestEncryptionAlgorithmId = var4;
- this.encryptedDigest = var5;
- }
-
- public SignerInfo(DerInputStream var1) throws IOException, ParsingException {
- this.version = var1.getInteger();
- DerValue[] var2 = var1.getSequence(2);
- byte[] var3 = var2[0].toByteArray();
- this.issuerName = new X500Name(new DerValue((byte)48, var3));
- this.certificateSerialNumber = var2[1].getInteger();
- DerValue var4 = var1.getDerValue();
- this.digestAlgorithmId = AlgorithmId.parse(var4);
- var1.getSet(0);
- var4 = var1.getDerValue();
- this.digestEncryptionAlgorithmId = AlgorithmId.parse(var4);
- this.encryptedDigest = var1.getOctetString();
- var1.getSet(0);
- if (var1.available() != 0) {
- throw new ParsingException("extra data at the end");
- }
- }
-
- public void encode(DerOutputStream var1) throws IOException {
- DerOutputStream var2 = new DerOutputStream();
- var2.putInteger(this.version);
- DerOutputStream var3 = new DerOutputStream();
- this.issuerName.emit(var3);
- var3.putInteger(this.certificateSerialNumber);
- var2.write((byte)48, var3);
- this.digestAlgorithmId.encode(var2);
- DerOutputStream var4 = new DerOutputStream();
- var2.write((byte)49, var4);
- this.digestEncryptionAlgorithmId.encode(var2);
- var2.putOctetString(this.encryptedDigest);
- var2.write((byte)49, var4);
- var1.write((byte)48, var2);
- }
-
- public X509Cert getCertificate(PKCS7 var1) {
- return var1.getCertificate(this.certificateSerialNumber, this.issuerName);
- }
-
- SignerInfo verify(PKCS7 var1, byte[] var2) throws NoSuchAlgorithmException, SignatureException {
- IdentityScope.getSystemScope();
-
- try {
- if (var2 == null) {
- ContentInfo var3 = var1.getContentInfo();
- var2 = var3.getContentBytes();
- }
-
- String var9 = this.getDigestEncryptionAlgorithmId().getName();
- Signature var4 = Signature.getInstance(var9);
- X509Cert var5 = this.getCertificate(var1);
- if (var5 == null) {
- throw new SignatureException("No cert for " + this.issuerName);
- } else {
- PublicKey var6 = var5.getPublicKey();
- var4.initVerify(var6);
- var4.update(var2);
- return var4.verify(this.encryptedDigest) ? this : null;
- }
- } catch (IOException var7) {
- throw new SignatureException("IO error verifying signature:\n" + ((Throwable)var7).getMessage());
- } catch (InvalidKeyException var8) {
- throw new SignatureException("InvalidKey: " + ((Throwable)var8).getMessage());
- }
- }
-
- SignerInfo verify(PKCS7 var1) throws NoSuchAlgorithmException, SignatureException {
- return this.verify(var1, (byte[])null);
- }
-
- public BigInt getVersion() {
- return this.version;
- }
-
- public X500Name getIssuerName() {
- return this.issuerName;
- }
-
- public BigInt getCertificateSerialNumber() {
- return this.certificateSerialNumber;
- }
-
- public AlgorithmId getDigestAlgorithmId() {
- return this.digestAlgorithmId;
- }
-
- public AlgorithmId getDigestEncryptionAlgorithmId() {
- return this.digestEncryptionAlgorithmId;
- }
-
- public byte[] getEncryptedDigest() {
- return this.encryptedDigest;
- }
-
- public String toString() {
- String var1 = "";
- var1 = var1 + "Signer Info for (issuer): " + this.issuerName + "\n";
- var1 = var1 + "\tversion: " + this.version + "\n";
- var1 = var1 + "\tcertificateSerialNumber: " + this.certificateSerialNumber + "\n";
- var1 = var1 + "\tdigestAlgorithmId: " + this.digestAlgorithmId + "\n";
- var1 = var1 + "\tdigestEncryptionAlgorithmId: " + this.digestEncryptionAlgorithmId + "\n";
- var1 = var1 + "\tencryptedDigest: " + this.encryptedDigest + "\n";
- return var1;
- }
- }
-