Search in sources :

Example 1 with KeyInformationExtractorBouncyCastle

use of won.cryptography.key.KeyInformationExtractorBouncyCastle in project webofneeds by researchstudio-sat.

the class CryptographyServiceTest method testInfoExractorOfKeyPairBrainpoolp384r1.

@Test
public void testInfoExractorOfKeyPairBrainpoolp384r1() {
    KeyPairService keyPairService = context.getBean("keyPairService", KeyPairService.class);
    KeyPair keypair = keyPairService.generateNewKeyPairInBrainpoolp384r1();
    KeyInformationExtractorBouncyCastle extractor = new KeyInformationExtractorBouncyCastle();
    try {
        Assert.assertEquals("ECDSA", extractor.getAlgorithm(keypair.getPublic()));
        logger.debug("algorithm: " + extractor.getAlgorithm(keypair.getPublic()));
        Assert.assertEquals("brainpoolp384r1", extractor.getCurveID(keypair.getPublic()));
        logger.debug("curveID: " + extractor.getCurveID(keypair.getPublic()));
        Assert.assertNotNull(extractor.getQX(keypair.getPublic()));
        logger.debug("qx: " + extractor.getQX(keypair.getPublic()));
        Assert.assertNotNull(extractor.getQY(keypair.getPublic()));
        logger.debug("qy: " + extractor.getQY(keypair.getPublic()));
    } catch (KeyNotSupportedException ex) {
        Assert.fail(ex.getMessage());
    }
}
Also used : KeyPair(java.security.KeyPair) KeyNotSupportedException(won.cryptography.exception.KeyNotSupportedException) KeyInformationExtractorBouncyCastle(won.cryptography.key.KeyInformationExtractorBouncyCastle) KeyPairService(won.cryptography.service.KeyPairService) Test(org.junit.Test)

Example 2 with KeyInformationExtractorBouncyCastle

use of won.cryptography.key.KeyInformationExtractorBouncyCastle in project webofneeds by researchstudio-sat.

the class CryptographyServiceTest method testInfoExtractorOfKeyPairSecp384r1.

@Test
public void testInfoExtractorOfKeyPairSecp384r1() {
    KeyPairService keyPairService = context.getBean("keyPairService", KeyPairService.class);
    KeyPair keypair = keyPairService.generateNewKeyPairInSecp384r1();
    KeyInformationExtractorBouncyCastle extractor = new KeyInformationExtractorBouncyCastle();
    try {
        Assert.assertEquals("ECDSA", extractor.getAlgorithm(keypair.getPublic()));
        logger.debug("algorithm: " + extractor.getAlgorithm(keypair.getPublic()));
        Assert.assertEquals("secp384r1", extractor.getCurveID(keypair.getPublic()));
        logger.debug("curveID: " + extractor.getCurveID(keypair.getPublic()));
        Assert.assertNotNull(extractor.getQX(keypair.getPublic()));
        logger.debug("qx: " + extractor.getQX(keypair.getPublic()));
        Assert.assertNotNull(extractor.getQY(keypair.getPublic()));
        logger.debug("qy: " + extractor.getQY(keypair.getPublic()));
    } catch (KeyNotSupportedException ex) {
        Assert.fail(ex.getMessage());
    }
}
Also used : KeyPair(java.security.KeyPair) KeyNotSupportedException(won.cryptography.exception.KeyNotSupportedException) KeyInformationExtractorBouncyCastle(won.cryptography.key.KeyInformationExtractorBouncyCastle) KeyPairService(won.cryptography.service.KeyPairService) Test(org.junit.Test)

Example 3 with KeyInformationExtractorBouncyCastle

use of won.cryptography.key.KeyInformationExtractorBouncyCastle in project webofneeds by researchstudio-sat.

the class WonKeysReaderWriter method writeToModel.

public static void writeToModel(Model model, Resource keySubject, PublicKey publicKey) throws NotSupportedException, KeyNotSupportedException {
    Objects.requireNonNull(keySubject);
    Objects.requireNonNull(publicKey);
    Objects.requireNonNull(model);
    KeyInformationExtractor info = new KeyInformationExtractorBouncyCastle();
    writeToModel(model, keySubject, new WonEccPublicKey(info.getCurveID(publicKey), info.getAlgorithm(publicKey), info.getQX(publicKey), info.getQY(publicKey)));
}
Also used : KeyInformationExtractorBouncyCastle(won.cryptography.key.KeyInformationExtractorBouncyCastle) KeyInformationExtractor(won.cryptography.key.KeyInformationExtractor)

Aggregations

KeyInformationExtractorBouncyCastle (won.cryptography.key.KeyInformationExtractorBouncyCastle)3 KeyPair (java.security.KeyPair)2 Test (org.junit.Test)2 KeyNotSupportedException (won.cryptography.exception.KeyNotSupportedException)2 KeyPairService (won.cryptography.service.KeyPairService)2 KeyInformationExtractor (won.cryptography.key.KeyInformationExtractor)1