Package java.security

Examples of java.security.SignatureException


        {
            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


            deros.writeObject(new DERSequence(pkac));
            deros.close();
        }
        catch (IOException ioe)
        {
            throw new SignatureException(ioe.getMessage());
        }

        sig.update(baos.toByteArray());

        sigBits = sig.sign();
View Full Code Here

      //  Covert array of Hex bytes to a String
      //result = new String(hexBytes, "ISO-8859-1");
    }
    catch (Exception e) {
      throw new SignatureException("Failed to generate HMAC : " + e.getMessage());
      }
    return hexMAC.toString();
    }
View Full Code Here

            Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM);
            mac.init(key);
            byte[] rawHmac = mac.doFinal(baseString.getBytes());
            return Base64.encode(rawHmac);
        } catch (Exception e) {
            throw new SignatureException("Failed to generate HMAC : " + e.getMessage());
        }
    }
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

        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

        {
            sig.update(reqInfo.getEncoded(ASN1Encodable.DER));
        }
        catch (Exception e)
        {
            throw new SignatureException("exception encoding TBS cert request - " + e);
        }

        return sig.verify(sigBits.getBytes());
    }
View Full Code Here

            {
                sigParams.init(params.getDERObject().getDEREncoded());
            }
            catch (IOException e)
            {
                throw new SignatureException("IOException decoding parameters: " + e.getMessage());
            }

            if (signature.getAlgorithm().endsWith("MGF1"))
            {
                try
                {
                    signature.setParameter(sigParams.getParameterSpec(PSSParameterSpec.class));
                }
                catch (GeneralSecurityException e)
                {
                    throw new SignatureException("Exception extracting parameters: " + e.getMessage());
                }
            }
        }
    }
View Full Code Here

            return derEncode(sig[0], sig[1]);
        }
        catch (Exception e)
        {
            throw new SignatureException(e.toString());
        }
    }
View Full Code Here

        {
            sig = derDecode(sigBytes);
        }
        catch (Exception e)
        {
            throw new SignatureException("error decoding signature bytes.");
        }

        return signer.verifySignature(hash, sig[0], sig[1]);
    }
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.