Package java.security

Examples of java.security.Signature.sign()


      throws OAuthException {
    try {
      Signature signer = Signature.getInstance("SHA1withRSA");
      signer.initSign(privateKey);
      signer.update(baseString.getBytes("UTF-8"));
      return Base64.encode(signer.sign());
    } catch (NoSuchAlgorithmException e) {
      throw new OAuthException("Error generating signature", e);
    } catch (InvalidKeyException e) {
      throw new OAuthException("Error generating signature", e);
    } catch (SignatureException e) {
View Full Code Here


                                            "generating RSA-SHA1 signatures.");
        }
        Signature signer = Signature.getInstance("SHA1withRSA");
        signer.initSign(privateKey);
        signer.update(message);
        return signer.sign();
    }

    private boolean verify(byte[] signature, byte[] message)
            throws GeneralSecurityException {
        if (publicKey == null) {
View Full Code Here

  byte [] outBytes = DNSSEC.digestMessage(tmpsig, m, old);
 
  Signature signer = Signature.getInstance(algorithmName);
  signer.initSign(privateKey);
  signer.update(outBytes);
  byte [] signature = signer.sign();

  /*
   * RSA signatures are already in correct format, but Java DSA
   * routines use ASN.1; convert this to SIG format.
   */
 
View Full Code Here

            sig.initSign(key);
        }

        sig.update(object.getEncoded(ASN1Encodable.DER));

        return sig.sign();
    }

    static byte[] calculateSignature(
        DERObjectIdentifier sigOid,
        String              sigName,
View Full Code Here

            sig.initSign(key);
        }

        sig.update(object.getEncoded(ASN1Encodable.DER));

        return sig.sign();
    }

    static X509Principal convertPrincipal(
        X500Principal principal)
    {
View Full Code Here

            ASN1EncodableVector  v = new ASN1EncodableVector();

            v.add(tbsCert);
            v.add(sigAlgId);
            v.add(new DERBitString(sig.sign()));

            return new X509CertificateObject(new X509CertificateStructure(new DERSequence(v)));
        }
        catch (Exception e)
        {
View Full Code Here

            dOut.writeObject(tbsResp);

            sig.update(bOut.toByteArray());

            bitSig = new DERBitString(sig.sign());
        }
        catch (Exception e)
        {
            throw new OCSPException("exception processing TBSRequest: " + e, e);
        }
View Full Code Here

            ASN1EncodableVector  v = new ASN1EncodableVector();

            v.add(tbsCert);
            v.add(sigAlgId);
            v.add(new DERBitString(sig.sign()));

            return new X509CertificateObject(new X509CertificateStructure(new DERSequence(v)));
        }
        catch (Exception e)
        {
View Full Code Here

        // Construct the CRL
        ASN1EncodableVector  v = new ASN1EncodableVector();

        v.add(tbsCrl);
        v.add(sigAlgId);
        v.add(new DERBitString(sig.sign()));

        try
        {
            return new X509CRLObject(new CertificateList(new DERSequence(v)));
        }
View Full Code Here

        catch (Exception e)
        {
            throw new IllegalArgumentException("exception encoding TBS cert request - " + e);
        }

        this.sigBits = new DERBitString(sig.sign());
    }

    /**
     * return the public key associated with the certification request -
     * the public key is created using the BC provider.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.