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());
}
}
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());
}
}
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)));
}
Aggregations