Package org.jboss.aerogear.crypto.signature

Examples of org.jboss.aerogear.crypto.signature.VerifyKey.verify()


    public void testSignMessageAsBytes() throws Exception {
        SigningKey key = new SigningKey();
        byte[] signMessage = HEX.decode(SIGN_MESSAGE);
        byte[] signedMessage = key.sign(HEX.decode(SIGN_MESSAGE));
        VerifyKey verifyKey = new VerifyKey(key.getPublicKey());
        Boolean isValid = verifyKey.verify(signMessage, signedMessage);
        assertTrue("Message sign has failed", isValid);
    }

    @Test
    public void testSignMessageAsHex() throws Exception {
View Full Code Here


    @Test
    public void testSignMessageAsHex() throws Exception {
        SigningKey key = new SigningKey();
        String signedMessage = key.sign(SIGN_MESSAGE, HEX);
        VerifyKey verifyKey = new VerifyKey(key.getPublicKey());
        Boolean isValid = verifyKey.verify(SIGN_MESSAGE, signedMessage, HEX);
        assertTrue("Message sign has failed", isValid);
    }

    @Test(expected = RuntimeException.class)
    public void testVerifyCorruptedSignature() throws Exception {
View Full Code Here

        SigningKey key = new SigningKey();
        byte[] signMessage = HEX.decode(SIGN_MESSAGE);
        byte[] corruptedSignature = key.sign(signMessage);
        corruptedSignature[0] = ' ';
        VerifyKey verifyKey = new VerifyKey(key.getPublicKey());
        Boolean isValid = verifyKey.verify(signMessage, corruptedSignature);
        assertTrue("Message sign has failed", isValid);
    }

    @Test
    public void testVerifyCorruptedMessage() throws Exception {
View Full Code Here

        SigningKey key = new SigningKey();
        byte[] signMessage = HEX.decode(SIGN_MESSAGE);
        byte[] signature = key.sign(HEX.decode(SIGN_MESSAGE));
        signMessage[0] = ' ';
        VerifyKey verifyKey = new VerifyKey(key.getPublicKey());
        Boolean isValid = verifyKey.verify(signMessage, signature);
        assertFalse("Message should be invalid", isValid);
    }
}
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.