Examples of sign()


Examples of java.security.Signature.sign()

                sign.update(buffer, 0, len);
            }
            bufin.close();

            /* generate unterschrift */
            byte[] realSig = sign.sign();

            /* save in to file �signature� */
            saveToFile(realSig, signFile);
        } catch (NoClassDefFoundError e) {
            throw new Exception("no such Definition : " + e);
View Full Code Here

Examples of java.security.Signature.sign()

        catch (Exception e)
        {
            throw new SecurityException("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

Examples of java.security.Signature.sign()

        ASN1EncodableVector  v = new ASN1EncodableVector();

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

        return new X509CertificateObject(new X509CertificateStructure(new DERSequence(v)));
    }
}
View Full Code Here

Examples of java.security.Signature.sign()

    private byte[] computeSignature(String stringToBeSigned, PrivateKey signingKey) throws GeneralSecurityException {
        String algo = signingKey.getAlgorithm();
        Signature sig = getSignature(algo);
        sig.initSign(signingKey);
        sig.update(stringToBeSigned.getBytes());
        return sig.sign();
    }

    public void validateSignature(SamlRedirectMessage urlEncodedRedirectMessage, PublicKey publicKey) throws InvalidRequestException {
        if (urlEncodedRedirectMessage.getSignature() == null) {
            throw new InvalidRequestException("Signature parameter is not present.");
View Full Code Here

Examples of java.security.Signature.sign()

        Signature sig = Signature.getInstance("SHA1with"+algorithm);
        sig.initSign(key.getPrivate());
        sig.update(key.getPublic().getEncoded());
        sig.update(sharedSecret);
        writeObject(sig.sign());
    }

    /**
     * Verifies that we are talking to a peer that actually owns the private key corresponding to the public key we get.
     */
 
View Full Code Here

Examples of java.security.Signature.sign()

            while(true) {
                Signature sig = Signature.getInstance(curve.defaultHashAlgorithm, curve.sigProvider);
                sig.initSign(key.getPrivate());
          for(byte[] d: data)
            sig.update(d);
                result = sig.sign();
                // It's a DER encoded signature, most sigs will fit in N bytes
                // If it doesn't let's re-sign.
                if(result.length <= curve.maxSigSize)
                  break;
                else
View Full Code Here

Examples of java.security.Signature.sign()

        random.nextBytes(sampleMessage);

        Signature normalSig = Signature.getInstance(sigName, "BC");
        normalSig.initSign(privKey);
        normalSig.update(sampleMessage);
        byte[] normalResult = normalSig.sign();

        MessageDigest digest = MessageDigest.getInstance(digestOID.getId(), "BC");
        byte[] hash = digest.digest(sampleMessage);
        byte[] digInfo = derEncode(digestOID, hash);
View Full Code Here

Examples of java.security.Signature.sign()

        byte[] digInfo = derEncode(digestOID, hash);

        Signature rawSig = Signature.getInstance("RSA", "BC");
        rawSig.initSign(privKey);
        rawSig.update(digInfo);
        byte[] rawResult = rawSig.sign();

        if (!Arrays.areEqual(normalResult, rawResult))
        {
            fail("raw mode signature differs from normal one");
        }
View Full Code Here

Examples of java.security.Signature.sign()

        Signature s = Signature.getInstance("SHA1withRSA/PSS", "BC");

        s.initSign(privKey, new FixedRandom(slt1a));
        s.update(msg1a);
        byte[] sig = s.sign();

        if (!arrayEquals(sig1a, sig))
        {
           fail("PSS Sign test expected " + new String(Hex.encode(sig1a)) + " got " + new String(Hex.encode(sig)));
        }
View Full Code Here

Examples of java.security.Signature.sign()

       
        s = Signature.getInstance("SHA256withRSA/PSS", "BC");

        s.initSign(privKey, new FixedRandom(slt1a));
        s.update(msg1a);
        sig = s.sign();

        pss = s.getParameters();
       
        if (!arrayEquals(sig1b, sig))
        {
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.