use of com.github.zhenwei.pkix.cms.RecipientOperator in project LinLong-Java by zhenwei1108.
the class BcRSAKeyTransEnvelopedRecipient method getRecipientOperator.
public RecipientOperator getRecipientOperator(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentEncryptionAlgorithm, byte[] encryptedContentEncryptionKey) throws CMSException {
CipherParameters secretKey = extractSecretKey(keyEncryptionAlgorithm, contentEncryptionAlgorithm, encryptedContentEncryptionKey);
final Object dataCipher = EnvelopedDataHelper.createContentCipher(false, secretKey, contentEncryptionAlgorithm);
return new RecipientOperator(new InputDecryptor() {
public AlgorithmIdentifier getAlgorithmIdentifier() {
return contentEncryptionAlgorithm;
}
public InputStream getInputStream(InputStream dataIn) {
if (dataCipher instanceof BufferedBlockCipher) {
return new CipherInputStream(dataIn, (BufferedBlockCipher) dataCipher);
} else {
return new CipherInputStream(dataIn, (StreamCipher) dataCipher);
}
}
});
}
use of com.github.zhenwei.pkix.cms.RecipientOperator in project LinLong-Java by zhenwei1108.
the class JceKEKAuthenticatedRecipient method getRecipientOperator.
public RecipientOperator getRecipientOperator(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentMacAlgorithm, byte[] encryptedContentEncryptionKey) throws CMSException {
final Key secretKey = extractSecretKey(keyEncryptionAlgorithm, contentMacAlgorithm, encryptedContentEncryptionKey);
final Mac dataMac = contentHelper.createContentMac(secretKey, contentMacAlgorithm);
return new RecipientOperator(new MacCalculator() {
public AlgorithmIdentifier getAlgorithmIdentifier() {
return contentMacAlgorithm;
}
public GenericKey getKey() {
return new JceGenericKey(contentMacAlgorithm, secretKey);
}
public OutputStream getOutputStream() {
return new MacOutputStream(dataMac);
}
public byte[] getMac() {
return dataMac.doFinal();
}
});
}
use of com.github.zhenwei.pkix.cms.RecipientOperator in project LinLong-Java by zhenwei1108.
the class JceKEKEnvelopedRecipient method getRecipientOperator.
public RecipientOperator getRecipientOperator(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentEncryptionAlgorithm, byte[] encryptedContentEncryptionKey) throws CMSException {
Key secretKey = extractSecretKey(keyEncryptionAlgorithm, contentEncryptionAlgorithm, encryptedContentEncryptionKey);
final Cipher dataCipher = contentHelper.createContentCipher(secretKey, contentEncryptionAlgorithm);
return new RecipientOperator(new InputDecryptor() {
public AlgorithmIdentifier getAlgorithmIdentifier() {
return contentEncryptionAlgorithm;
}
public InputStream getInputStream(InputStream dataOut) {
return new CipherInputStream(dataOut, dataCipher);
}
});
}
use of com.github.zhenwei.pkix.cms.RecipientOperator in project LinLong-Java by zhenwei1108.
the class JcePasswordEnvelopedRecipient method getRecipientOperator.
public RecipientOperator getRecipientOperator(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentEncryptionAlgorithm, byte[] derivedKey, byte[] encryptedContentEncryptionKey) throws CMSException {
Key secretKey = extractSecretKey(keyEncryptionAlgorithm, contentEncryptionAlgorithm, derivedKey, encryptedContentEncryptionKey);
final Cipher dataCipher = helper.createContentCipher(secretKey, contentEncryptionAlgorithm);
return new RecipientOperator(new InputDecryptor() {
public AlgorithmIdentifier getAlgorithmIdentifier() {
return contentEncryptionAlgorithm;
}
public InputStream getInputStream(InputStream dataOut) {
return new CipherInputStream(dataOut, dataCipher);
}
});
}
use of com.github.zhenwei.pkix.cms.RecipientOperator in project LinLong-Java by zhenwei1108.
the class JceKeyTransAuthEnvelopedRecipient method getRecipientOperator.
public RecipientOperator getRecipientOperator(AlgorithmIdentifier keyEncryptionAlgorithm, final AlgorithmIdentifier contentEncryptionAlgorithm, byte[] encryptedContentEncryptionKey) throws CMSException {
Key secretKey = extractSecretKey(keyEncryptionAlgorithm, contentEncryptionAlgorithm, encryptedContentEncryptionKey);
final Cipher dataCipher = contentHelper.createContentCipher(secretKey, contentEncryptionAlgorithm);
return new RecipientOperator(new InputAEADDecryptor() {
public AlgorithmIdentifier getAlgorithmIdentifier() {
return contentEncryptionAlgorithm;
}
public InputStream getInputStream(InputStream dataIn) {
return new CipherInputStream(dataIn, dataCipher);
}
public OutputStream getAADStream() {
return new AADStream(dataCipher);
}
public byte[] getMAC() {
// TODO
return new byte[0];
}
});
}
Aggregations