Package java.security

Examples of java.security.SignatureException


            sig[0] = new BigInteger(1, r);
            sig[1] = new BigInteger(1, s);
        }
        catch (Exception e)
        {
            throw new SignatureException("error decoding signature bytes.");
        }

        return signer.verifySignature(hash, sig[0], sig[1]);
    }
View Full Code Here


        {
            signature.update(cert.getAcinfo().getEncoded());
        }
        catch (IOException e)
        {
            throw new SignatureException("Exception encoding certificate info object");
        }

        if (!signature.verify(this.getSignature()))
        {
            throw new InvalidKeyException("Public key presented not for certificate signature");
View Full Code Here

        if (signature != null) {
            signature.update(answer);
            PGPSignatureList sigList = (PGPSignatureList) pgpFactory.nextObject();
            if (!signature.verify(sigList.get(0))) {
                throw new SignatureException("Cannot verify PGP signature");
            }
        }

        return answer;
    }
View Full Code Here

        }

        if (signature != null) {
            PGPSignatureList sigList = (PGPSignatureList) pgpFactory.nextObject();
            if (!signature.verify(getSignatureWithKeyId(signature.getKeyID(), sigList))) {
                throw new SignatureException("Cannot verify PGP signature");
            }
        }
       
        if (cos != null) {
            return cos.newStreamCache();
View Full Code Here

        }

        if (signature != null) {
            PGPSignatureList sigList = (PGPSignatureList) pgpFactory.nextObject();
            if (!signature.verify(getSignatureWithKeyId(signature.getKeyID(), sigList))) {
                throw new SignatureException("Cannot verify PGP signature");
            }
        }

        if (cos != null) {
            return cos.newStreamCache();
View Full Code Here

    private void verifySignature(PGPObjectFactory pgpFactory, PGPOnePassSignature signature) throws IOException, PGPException, SignatureException {
        if (signature != null) {
            PGPSignatureList sigList = (PGPSignatureList) pgpFactory.nextObject();
            if (!signature.verify(getSignatureWithKeyId(signature.getKeyID(), sigList))) {
                throw new SignatureException("Verification of the PGP signature with the key ID " + signature.getKeyID() + " failed. The PGP message may have been tampered.");
            }
        }
    }
View Full Code Here

            return sig;
        }
        catch (Exception e)
        {
            throw new SignatureException(e.toString());
        }
    }
View Full Code Here

throws SignatureException
{
  int rLength, sLength;
  int rOffset, sOffset;
  if ((sig[0] != ASN1_SEQ) || (sig[2] != ASN1_INT))
    throw new SignatureException("Expected SEQ, INT");
  rLength = sig[3];
  rOffset = 4;
  if (sig[rOffset] == 0) {
    rLength--;
    rOffset++;
  }
  if (sig[rOffset+rLength] != ASN1_INT)
    throw new SignatureException("Expected INT");
  sLength = sig[rOffset + rLength + 1];
  sOffset = rOffset + rLength + 2;
  if (sig[sOffset] == 0) {
    sLength--;
    sOffset++;
  }

  if ((rLength > 20) || (sLength > 20))
    throw new SignatureException("DSA R/S too long");

  byte[] newSig = new byte[41];
  Arrays.fill(newSig, (byte) 0);
  newSig[0] = (byte) ((params.getP().bitLength() - 512)/64);
  System.arraycopy(sig, rOffset, newSig, 1 + (20 - rLength), rLength);
View Full Code Here

    byte tagNumber = (byte) (buffer[offset] & 0x1f);
    if (tagNumber < 32) {
      tag = tagNumber;
      endOffset = offset + 1;
    } else {
      throw new SignatureException("Can't handle tags > 32"); //$NON-NLS-1$
    }
    if ((buffer[endOffset] & 0x80) == 0) {
      // section 8.1.3.4 (doing the short form of the length)
      contentLength = buffer[endOffset];
      endOffset++;
    } else {
      // section 8.1.3.5 (doing the long form of the length)
      int octetCount = buffer[endOffset] & 0x7f;
      if (octetCount > 3)
        throw new SignatureException("ContentLength octet count too large: " + octetCount); //$NON-NLS-1$
      contentLength = 0;
      endOffset++;
      for (int i = 0; i < octetCount; i++) {
        contentLength <<= 8;
        contentLength |= buffer[endOffset] & 0xff;
        endOffset++;
      }
      // section 8.1.3.6 (doing the indefinite form
      if (octetCount == 0)
        contentLength = -1;
    }
    contentOffset = endOffset;
    if (contentLength != -1)
      endOffset += contentLength;
    if (endOffset > lastOffset)
      throw new SignatureException("Content length too large: " + endOffset + " > " + lastOffset); //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here

        sig.initVerify(key);
        sig.update(this.getTBSCertList());
        if (!sig.verify(this.getSignature()))
        {
            throw new SignatureException("CRL does not verify with supplied public key.");
        }
    }
View Full Code Here

TOP

Related Classes of java.security.SignatureException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.