public JceKEKRecipientInfoGenerator(KEKIdentifier kekIdentifier, SecretKey keyEncryptionKey) { super(kekIdentifier, new JceSymmetricKeyWrapper(keyEncryptionKey)); }
public JceSymmetricKeyWrapper(SecretKey wrappingKey) { super(determineKeyEncAlg(wrappingKey)); this.wrappingKey = wrappingKey; }
public JceKEKRecipientInfoGenerator setProvider(String providerName) { ((JceSymmetricKeyWrapper)this.wrapper).setProvider(providerName); return this; }
public JceKEKRecipientInfoGenerator setSecureRandom(SecureRandom random) { ((JceSymmetricKeyWrapper)this.wrapper).setSecureRandom(random); return this; } }
public byte[] generateWrappedKey(GenericKey encryptionKey) throws OperatorException { Key contentEncryptionKeySpec = OperatorUtils.getJceKey(encryptionKey); Cipher keyEncryptionCipher = helper.createSymmetricWrapper(this.getAlgorithmIdentifier().getAlgorithm()); try { keyEncryptionCipher.init(Cipher.WRAP_MODE, wrappingKey, random); return keyEncryptionCipher.wrap(contentEncryptionKeySpec); } catch (GeneralSecurityException e) { throw new OperatorException("cannot wrap key: " + e.getMessage(), e); } }
public JceKEKRecipientInfoGenerator setSecureRandom(SecureRandom random) { ((JceSymmetricKeyWrapper)this.wrapper).setSecureRandom(random); return this; } }
public byte[] generateWrappedKey(GenericKey encryptionKey) throws OperatorException { Key contentEncryptionKeySpec = OperatorUtils.getJceKey(encryptionKey); Cipher keyEncryptionCipher = helper.createSymmetricWrapper(this.getAlgorithmIdentifier().getAlgorithm()); try { keyEncryptionCipher.init(Cipher.WRAP_MODE, wrappingKey, random); return keyEncryptionCipher.wrap(contentEncryptionKeySpec); } catch (GeneralSecurityException e) { throw new OperatorException("cannot wrap key: " + e.getMessage(), e); } }
public JceSymmetricKeyWrapper(SecretKey wrappingKey) { super(determineKeyEncAlg(wrappingKey)); this.wrappingKey = wrappingKey; }
public JceKEKRecipientInfoGenerator setProvider(Provider provider) { ((JceSymmetricKeyWrapper)this.wrapper).setProvider(provider); return this; }
public JceKEKRecipientInfoGenerator(KEKIdentifier kekIdentifier, SecretKey keyEncryptionKey) { super(kekIdentifier, new JceSymmetricKeyWrapper(keyEncryptionKey)); }
private static AlgorithmIdentifier determineKeyEncAlg(SecretKey key) { return determineKeyEncAlg(key.getAlgorithm(), key.getEncoded().length * 8); }
public JceKEKRecipientInfoGenerator setProvider(String providerName) { ((JceSymmetricKeyWrapper)this.wrapper).setProvider(providerName); return this; }
private static AlgorithmIdentifier determineKeyEncAlg(SecretKey key) { return determineKeyEncAlg(key.getAlgorithm(), key.getEncoded().length * 8); }
public JceKEKRecipientInfoGenerator setProvider(Provider provider) { ((JceSymmetricKeyWrapper)this.wrapper).setProvider(provider); return this; }
public byte[] generateWrappedKey(GenericKey encryptionKey) throws OperatorException { Cipher keyEncryptionCipher = helper.createAsymmetricWrapper(getAlgorithmIdentifier().getAlgorithm(), new HashMap()); try { DEROtherInfo otherInfo = new DEROtherInfo.Builder(JceSymmetricKeyWrapper.determineKeyEncAlg(symmetricWrappingAlg, keySizeInBits), partyUInfo, partyVInfo).build(); KTSParameterSpec ktsSpec = new KTSParameterSpec.Builder(symmetricWrappingAlg, keySizeInBits, otherInfo.getEncoded()).build(); keyEncryptionCipher.init(Cipher.WRAP_MODE, publicKey, ktsSpec, random); return keyEncryptionCipher.wrap(OperatorUtils.getJceKey(encryptionKey)); } catch (Exception e) { throw new OperatorException("Unable to wrap contents key: " + e.getMessage(), e); } } }
public byte[] generateWrappedKey(GenericKey encryptionKey) throws OperatorException { Cipher keyEncryptionCipher = helper.createAsymmetricWrapper(getAlgorithmIdentifier().getAlgorithm(), new HashMap()); try { DEROtherInfo otherInfo = new DEROtherInfo.Builder(JceSymmetricKeyWrapper.determineKeyEncAlg(symmetricWrappingAlg, keySizeInBits), partyUInfo, partyVInfo).build(); KTSParameterSpec ktsSpec = new KTSParameterSpec.Builder(symmetricWrappingAlg, keySizeInBits, otherInfo.getEncoded()).build(); keyEncryptionCipher.init(Cipher.WRAP_MODE, publicKey, ktsSpec, random); return keyEncryptionCipher.wrap(OperatorUtils.getJceKey(encryptionKey)); } catch (Exception e) { throw new OperatorException("Unable to wrap contents key: " + e.getMessage(), e); } } }
public JceKTSKeyWrapper(PublicKey publicKey, String symmetricWrappingAlg, int keySizeInBits, byte[] partyUInfo, byte[] partyVInfo) { super(new AlgorithmIdentifier(PKCSObjectIdentifiers.id_rsa_KEM, new GenericHybridParameters(new AlgorithmIdentifier(ISOIECObjectIdentifiers.id_kem_rsa, new RsaKemParameters(new AlgorithmIdentifier(X9ObjectIdentifiers.id_kdf_kdf3, new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256)), (keySizeInBits + 7) / 8)), JceSymmetricKeyWrapper.determineKeyEncAlg(symmetricWrappingAlg, keySizeInBits)))); this.publicKey = publicKey; this.symmetricWrappingAlg = symmetricWrappingAlg; this.keySizeInBits = keySizeInBits; this.partyUInfo = Arrays.clone(partyUInfo); this.partyVInfo = Arrays.clone(partyVInfo); }
public JceKTSKeyWrapper(PublicKey publicKey, String symmetricWrappingAlg, int keySizeInBits, byte[] partyUInfo, byte[] partyVInfo) { super(new AlgorithmIdentifier(PKCSObjectIdentifiers.id_rsa_KEM, new GenericHybridParameters(new AlgorithmIdentifier(ISOIECObjectIdentifiers.id_kem_rsa, new RsaKemParameters(new AlgorithmIdentifier(X9ObjectIdentifiers.id_kdf_kdf3, new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256)), (keySizeInBits + 7) / 8)), JceSymmetricKeyWrapper.determineKeyEncAlg(symmetricWrappingAlg, keySizeInBits)))); this.publicKey = publicKey; this.symmetricWrappingAlg = symmetricWrappingAlg; this.keySizeInBits = keySizeInBits; this.partyUInfo = Arrays.clone(partyUInfo); this.partyVInfo = Arrays.clone(partyVInfo); }