@Test public void testLoadValidRawPublicKey() throws IOException, GeneralSecurityException { byte[] testRsaPublicKey = TestUtils.getBytes("rsa_public_key.dat"); byte[] rawPublicKey = WrappedRsaEcdsaPublicKey.newBuilder() .setPadding(Padding.OAEP.name()) .setKeyBytes(ByteString.copyFrom(testRsaPublicKey)) .build().toByteArray(); encrypterManager.rawLoadPublicKey(rawPublicKey); }
@Override HybridEncrypt rawLoadPublicKey(byte[] publicKey) throws GeneralSecurityException { WrappedRsaEcdsaPublicKey wrappedRsaEcdsaPublicKey; try { wrappedRsaEcdsaPublicKey = WrappedRsaEcdsaPublicKey.parseFrom(publicKey); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("unable to parse public key", e); } PublicKey recipientPublicKey = KeyFactory.getInstance("RSA").generatePublic( new X509EncodedKeySpec(wrappedRsaEcdsaPublicKey.getKeyBytes().toByteArray())); return new RsaEcdsaHybridEncrypt.Builder() .withSenderSigner(senderSigner) .withRecipientPublicKey(recipientPublicKey) .withPadding(RsaEcdsaConstants.Padding.valueOf(wrappedRsaEcdsaPublicKey.getPadding())) .build(); }
RsaEcdsaEncrypterManager extends EncrypterManager { @Override HybridEncrypt rawLoadPublicKey(byte[] publicKey) throws GeneralSecurityException { WrappedRsaEcdsaPublicKey wrappedRsaEcdsaPublicKey; try { wrappedRsaEcdsaPublicKey = WrappedRsaEcdsaPublicKey.parseFrom(publicKey); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("unable to parse public key", e); } PublicKey recipientPublicKey = KeyFactory.getInstance("RSA").generatePublic( new X509EncodedKeySpec(wrappedRsaEcdsaPublicKey.getKeyBytes().toByteArray())); return new RsaEcdsaHybridEncrypt.Builder() .withSenderSigner(senderSigner) .withRecipientPublicKey(recipientPublicKey) .withPadding(RsaEcdsaConstants.Padding.valueOf(wrappedRsaEcdsaPublicKey.getPadding())) .build(); } }
RsaEcdsaEncrypterManager extends EncrypterManager { @Override HybridEncrypt rawLoadPublicKey(byte[] publicKey) throws GeneralSecurityException { WrappedRsaEcdsaPublicKey wrappedRsaEcdsaPublicKey; try { wrappedRsaEcdsaPublicKey = WrappedRsaEcdsaPublicKey.parseFrom(publicKey); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("unable to parse public key", e); } PublicKey recipientPublicKey = KeyFactory.getInstance("RSA").generatePublic( new X509EncodedKeySpec(wrappedRsaEcdsaPublicKey.getKeyBytes().toByteArray())); return new RsaEcdsaHybridEncrypt.Builder() .withSenderSigner(senderSigner) .withRecipientPublicKey(recipientPublicKey) .withPadding(RsaEcdsaConstants.Padding.valueOf(wrappedRsaEcdsaPublicKey.getPadding())) .build(); } RsaEcdsaEncrypterManager(InputStream senderSigningKey); }
RsaEcdsaEncrypterManager extends EncrypterManager { @Override HybridEncrypt rawLoadPublicKey(byte[] publicKey) throws GeneralSecurityException { WrappedRsaEcdsaPublicKey wrappedRsaEcdsaPublicKey; try { wrappedRsaEcdsaPublicKey = WrappedRsaEcdsaPublicKey.parseFrom(publicKey); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("unable to parse public key", e); } PublicKey recipientPublicKey = KeyFactory.getInstance("RSA").generatePublic( new X509EncodedKeySpec(wrappedRsaEcdsaPublicKey.getKeyBytes().toByteArray())); return new RsaEcdsaHybridEncrypt.Builder() .withSenderSigner(senderSigner) .withRecipientPublicKey(recipientPublicKey) .withPadding(RsaEcdsaConstants.Padding.valueOf(wrappedRsaEcdsaPublicKey.getPadding())) .build(); } RsaEcdsaEncrypterManager(InputStream senderSigningKey);  }
RsaEcdsaEncrypterManager extends EncrypterManager { @Override HybridEncrypt rawLoadPublicKey(byte[] publicKey) throws GeneralSecurityException { WrappedRsaEcdsaPublicKey wrappedRsaEcdsaPublicKey; try { wrappedRsaEcdsaPublicKey = WrappedRsaEcdsaPublicKey.parseFrom(publicKey); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("unable to parse public key", e); } PublicKey recipientPublicKey = KeyFactory.getInstance("RSA").generatePublic( new X509EncodedKeySpec(wrappedRsaEcdsaPublicKey.getKeyBytes().toByteArray())); return new RsaEcdsaHybridEncrypt.Builder() .withSenderSigner(senderSigner) .withRecipientPublicKey(recipientPublicKey) .withPadding(RsaEcdsaConstants.Padding.valueOf(wrappedRsaEcdsaPublicKey.getPadding())) .build(); } RsaEcdsaEncrypterManager(InputStream senderSigningKey);   }