1 7 8 9 package org.enhydra.oyster.cms; 10 11 import org.enhydra.oyster.exception.SMIMEException; 12 import org.enhydra.oyster.der.DERSequencePr; 13 import java.security.cert.X509Certificate ; 14 import org.enhydra.oyster.crypto.AsymmetricEncryption; 15 16 17 34 public class KeyTransRecipientInfo extends DERSequencePr { 35 36 39 private byte[] symmetricKey; 40 41 44 private int enable = 0; 45 46 51 public KeyTransRecipientInfo (byte[] symKey0) throws SMIMEException 52 { 53 symmetricKey = symKey0; } 55 56 63 public void addRecipient (X509Certificate recip0) throws SMIMEException { 64 if (enable == 1) 65 throw new SMIMEException(this, 1022); 66 super.addContent(new CMSVersion(0).getDEREncoded()); super.addContent(new RecipientIdentifier(recip0).getDEREncoded()); super.addContent(new AlgorithmIdentifier("RSA", "NAME_STRING").getDEREncoded()); AsymmetricEncryption encrAsymmetric = new AsymmetricEncryption(); encrAsymmetric.encrypt(recip0.getPublicKey(), symmetricKey); 71 EncryptedKey encKey = new EncryptedKey(encrAsymmetric.getEncryptedValue()); 72 super.addContent(encKey.getDEREncoded()); enable = 1; 74 } 75 } 76 77 78 79 | Popular Tags |