/** * Static method to create a BinaryKeysetReader from an {@link InputStream}. * * <p>Note: the input stream won't be read until {@link BinaryKeysetReader#read} or {@link * BinaryKeysetReader#readEncrypted} is called. */ public static KeysetReader withInputStream(InputStream stream) { return new BinaryKeysetReader(stream); }
try { symmetricKeyHandle = CleartextKeysetHandle.read(BinaryKeysetReader.withBytes(symmetricKeyBytes)); } catch (IOException e) { throw new GeneralSecurityException("hybrid rsa decryption failed: ", e);
/** * Constructs a new RSA-ECDSA EncrypterManager. * * <p>Please note that the {@link InputStream} {@code senderSigningKey} will not be closed. * * @param senderSigningKey the serialized Tink signing key. * @throws GeneralSecurityException if the initialization fails. * @throws IOException if the given sender signing key cannot be read. */ public RsaEcdsaEncrypterManager(InputStream senderSigningKey) throws GeneralSecurityException, IOException { KeysetHandle signingKeyHandle = CleartextKeysetHandle .read(BinaryKeysetReader.withInputStream(senderSigningKey)); senderSigner = PublicKeySignFactory.getPrimitive(signingKeyHandle); }
try { symmetricKeyHandle = CleartextKeysetHandle.read(BinaryKeysetReader.withBytes(symmetricKeyBytes)); } catch (IOException e) { throw new GeneralSecurityException("hybrid rsa decryption failed: ", e);
/** * Constructs a new RSA-ECDSA EncrypterManager. * * <p>Please note that the {@link InputStream} {@code senderSigningKey} will not be closed. * * @param senderSigningKey the serialized Tink signing key. * @throws GeneralSecurityException if the initialization fails. * @throws IOException if the given sender signing key cannot be read. */ public RsaEcdsaEncrypterManager(InputStream senderSigningKey) throws GeneralSecurityException, IOException { KeysetHandle signingKeyHandle = CleartextKeysetHandle .read(BinaryKeysetReader.withInputStream(senderSigningKey)); senderSigner = PublicKeySignFactory.getPrimitive(signingKeyHandle); }
static PublicKeyVerify createTestSenderVerifier() throws GeneralSecurityException, IOException { KeysetHandle verificationKeyHandle = CleartextKeysetHandle .read(BinaryKeysetReader.withBytes(TestUtils.getBytes("verification_key.dat"))); return PublicKeyVerifyFactory.getPrimitive(verificationKeyHandle); }
/** * Static method to create a BinaryKeysetReader from a file. * * <p>Note: the input file won't be read until {@link BinaryKeysetReader#read} or {@link * BinaryKeysetReader#readEncrypted} is called. */ public static KeysetReader withFile(File file) throws IOException { return new BinaryKeysetReader(new FileInputStream(file)); }
static PublicKeySign createTestSenderSigner() throws GeneralSecurityException, IOException { KeysetHandle signingKeyHandle = CleartextKeysetHandle .read(BinaryKeysetReader.withBytes(TestUtils.getBytes("signing_key.dat"))); return PublicKeySignFactory.getPrimitive(signingKeyHandle); }
/** Static method to create a BinaryKeysetReader from a byte arrary. */ public static KeysetReader withBytes(final byte[] bytes) { return new BinaryKeysetReader(new ByteArrayInputStream(bytes)); }