Running ESPEncodeMessage

The ESPEncodeMessage sample application generates a secured file for Entrust Entelligence Security Provider (ESP) 9.3 or higher. The file is protected with both:

  • A password, to illustrate the use of the PasswordRecipientInfo CMS type described in ​RFC 3211.

  • An X509 encryption certificate, to illustrate the use of The KeyTransRecipientInfo CMS type described in ​RFC 2630.

To run this sample application, execute the following command line in the etjava/examples directory.

java -classpath classes;../lib/enttoolkit.jar;<jakarta.mail-api.jar> com.entrust.toolkit.examples.cms.ESPEncodeMessage <in_file> <pwd> <epf_file> <epf_pwd> <out_file>

Parameter

Value

<jakarta.mail-api.jar>

The path on your computer of the angus-mail.jar third-party library downloaded from https://eclipse-ee4j.github.io/angus-mail/#Download_Angus_Mail_Release

<in_file>

The path of the input file to encode.

<pwd>

The password to encode the file.

<epf_file>

The path of an Entrust user profile in .epf file format.

<epf_pwd>

The password for accessing the Entrust profile.

<out_file>

The path of the encoded output file.

For example :

C:\etjava\examples>java -classpath classes;..\lib\enttoolkit.jar;c:\java\lib\jakarta.mail-api.jar com.entrust.toolkit.examples.cms.ESPEncodeMessage plaintextFile.txt ~TestPassword~ C:\etjava\examples\data\userdata\RSAUser2.epf ~Sample7~ fileEncryptedForESPUser.pp7m
Login into user profile successful
Recipient's encryption certificate retrieved from user profile C:\etjava\examples\data\userdata\RSAUser2.epf
 
Output Authenticated data: 30:80:06:0B:2A:86:48:86:F7:0D:01:09:10:01:02:A0:80:30:80:02:01:00:31:82:01:C6:A3:81:80:02:01:00:A0:1B:0
...rest of output truncated...
 
MAC: C2:71:9C:85:D5:5A:4A:62:A8:A1:97:4D:4D:65:DC:EA:99:C2:2B:0C:1A:2E:56:13:91:B7:72:26:58:32:F1:7A
 
Encrypted Data: 30:80:06:09:2A:86:48:86:F7:0D:01:07:03:A0:80:30:80:02:01:00:31:82:01:C6:30:82:01:3F:02:01:00:30:27:30:1F:31:0B:30:
...rest of output truncated...
 
Encrypted file created: fileEncryptedForESPUser.pp7m

Running the ESPEncodeMessage sample to encode with a password and a certificate file

In the etjava/examples directory, run the following command to encode an input file with a password and the X.509 encryption certificate in a file.

java -classpath classes;../lib/enttoolkit.jar;<angus-mail.jar> com.entrust.toolkit.examples.cms.ESPEncodeMessage <in_file> <pwd> <cert> <out-file>

Parameter

Value

<in_file>

The path of the input file to encode.

<pwd>

The password to encode the file.

<cert>

The path of a file containing an X.509 encryption certificate.

<out_file>

The path of the encoded output file.

To encode with the X.509 certificate in a file.

C:\etjava\examples>java -classpath classes;..\lib\enttoolkit.jar;c:\java\lib\jakarta.mail-api.jar com.entrust.toolkit.examples.cms.ESPEncodeMessage plaintextFile.txt ~TestPassword~ C:\etjava\examples\data\userdata\RSAUser2Encryption.cer fileEncryptedForESP.pp7m
Recipient's encryption certificate obtained from file C:\etjava\examples\data\userdata\RSAUser2Encryption.cer
 
Output Authenticated data: 30:80:06:0B:2A:86:48:86:F7:0D:01:09:10:01:02:A0:80:30:80:02:01:00:31:82:01:C6:A3:81:80:02:01:00:A0:1B:0
...rest of output truncated...
 
MAC: B5:C9:01:39:C2:84:6F:D7:B9:A5:7B:84:EB:84:2F:DB:7F:BC:34:96:4A:1E:F6:15:D1:44:F4:0B:E4:86:9F:C8
 
Encrypted Data: 30:80:06:09:2A:86:48:86:F7:0D:01:07:03:A0:80:30:80:02:01:00:31:82:01:C6:30:82:01:3F:02:01:00:30:27:30:1F:31:0B:30:
...rest of output truncated...
 
Encrypted file created: fileEncryptedForESP.pp7m