Search in sources :

Example 1 with UserPrivateKey

use of com.dracoon.sdk.crypto.model.UserPrivateKey in project cyberduck by iterate-ch.

the class TripleCryptConverter method toCryptoUserKeyPair.

public static UserKeyPair toCryptoUserKeyPair(final UserKeyPairContainer c) throws UnknownVersionException {
    final UserPrivateKey privateKey = new UserPrivateKey(UserKeyPair.Version.getByValue(c.getPrivateKeyContainer().getVersion()), c.getPrivateKeyContainer().getPrivateKey());
    final UserPublicKey publicKey = new UserPublicKey(UserKeyPair.Version.getByValue(c.getPublicKeyContainer().getVersion()), c.getPublicKeyContainer().getPublicKey());
    return new UserKeyPair(privateKey, publicKey);
}
Also used : UserKeyPair(com.dracoon.sdk.crypto.model.UserKeyPair) UserPublicKey(com.dracoon.sdk.crypto.model.UserPublicKey) UserPrivateKey(com.dracoon.sdk.crypto.model.UserPrivateKey)

Example 2 with UserPrivateKey

use of com.dracoon.sdk.crypto.model.UserPrivateKey in project cyberduck by iterate-ch.

the class CryptoDecryptPrivateKeyTest method testDecryptPrivateKey.

@Test
public void testDecryptPrivateKey() throws Exception {
    final String pk = "-----BEGIN ENCRYPTED PRIVATE KEY-----\n" + "MIIFnDCBxQYJKoZIhvcNAQUNMIG3MIGVBgkqhkiG9w0BBQwwgYcEgYAzxG7mDxu4\n" + "TYtue+YQykOFgXlbFSJ9wbvVhVlbJP/16jewb4DhMZ/EWGzufLougL1WCwMc0BGM\n" + "wiozMk3Xl7kYCILBe78dsfS8bDZG9bMyS3PBuUn5Zuo4hhNMMtrJ4qYIOXYKsjml\n" + "rq5aipZXy3d/nfaHpGYTLGJTvSyZKDaGaQICJxAwHQYJYIZIAWUDBAEqBBDBxJJq\n" + "F0v+NbVvALtyDqOyBIIE0Kx8ce2gVTbC4FAowW/cV2texJWMZDe/i/NcTYvXide7\n" + "d8abj23zxWMT6+h89d27mXOD5BQMyXZSXMNAzHoMq2T0/uJwHNbm9VSXIZWrJ1wT\n" + "AHaipyUY5oQ3L0eu5CWqXISspRL7xlLAuIptpHunJIcvM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ZLLN0VYAAir31r5DAwAJiQ3lhregBgUYkNMRdBhsn3jLGzPxByGw/3\n" + "QXRJUq0+ZnKlI1y83XsfDTrsyY3jgua1P4MOrk5Khkpz6pcz3nGIsAXpsymPfFYm\n" + "rTXEaVVe9F+5UM8LzIQH7TyGL7c4mGTnUTBY3LE27whIusvZDq21maRU+8A84bFn\n" + "xCvFHXQs53NV3Tb4ZHl5SrdJllC/MYrj4xau3g1cRS0xJSUaW7FLa2AgC9/Ps8uL\n" + "7nVnJ6nKLBMejBfrK0+uFqGuGDP4jOl8H26V+dycY/5ecBYhF9Bts5aKEFhkqibG\n" + "2Qt3tuP/WvAzJAAFw+YYTKUyW8YvDh1hf74cD8RxiNYZ0UuVoqADxbycNZ3+26rC\n" + "lnXEetmYD961oHZclzis4CUcDbLRbgcmv/fvpoj9OIgBOumB/1ku0ZmicXvlJ6wD\n" + "S+2l6QSAHZF3rmD0D7lSGMu0rdF648h8HkLsoABONdoHJrCE5ehnBvSLd34Hdwt7\n" + "-----END ENCRYPTED PRIVATE KEY-----\n";
    final UserPrivateKey privateKey = new UserPrivateKey(UserKeyPair.Version.RSA2048, pk);
    final UserPublicKey publicKey = new UserPublicKey(UserKeyPair.Version.RSA2048, "pubkey");
    final UserKeyPair pair = new UserKeyPair(privateKey, publicKey);
    Assert.assertTrue(Crypto.checkUserKeyPair(pair, "abcdabc1"));
}
Also used : UserKeyPair(com.dracoon.sdk.crypto.model.UserKeyPair) UserPublicKey(com.dracoon.sdk.crypto.model.UserPublicKey) UserPrivateKey(com.dracoon.sdk.crypto.model.UserPrivateKey) Test(org.junit.Test)

Aggregations

UserKeyPair (com.dracoon.sdk.crypto.model.UserKeyPair)2 UserPrivateKey (com.dracoon.sdk.crypto.model.UserPrivateKey)2 UserPublicKey (com.dracoon.sdk.crypto.model.UserPublicKey)2 Test (org.junit.Test)1