Sign and Encrypt File
  • 20 Mar 2024
  • 4 Minutes to read
  • Dark
    Light

Sign and Encrypt File

  • Dark
    Light

Article summary

Step Details

Introduced in Version4.0.0
Last Modified in Version8.1.0
LocationPGP Steps

The Sign and Encrypt File step allows a user to sign a file and encrypt it.




Upgrading to v8.13+


Customers using the Sign File, Clear Sign File, or Sign And Encrypt File steps need to drag and drop these steps after upgrade into the Flows using them.

Steps that are already in Flows may have their mapping set to Null on upgrade.


Prerequisites 

This step requires the PGP module to be installed before it will be available in the toolbox. 


Properties

Inputs

PropertyDescriptionData Type
Algorithm Allows the user to select a Hash Algorithm type from a dropdown list (MD5, Sha1, RipeMD160, DoubleSha, MD2, Tiger192, Havel5pass160, Sha256, Sha384, Sha512, Sha224). To see the dropdown list, select the Constant input mapping.HashAlgorithmTag
Binary Defines whether the output file is encrypted as bytes or raw text/ascii
Boolean
DataThe desired file to sign and encrypt
List of Byte
Internal File LabelSpecifies the name of the internal file of the signed and encrypted file
String
Output File NameAllows the user to specify the file name and file extension for the signed file (i.e., SignednewFile.pdf)
String
Private KeyGenerated PGP Private Key file
List of Byte
Private Key PasswordPassword for the specified Private Key file
String
Public KeyGenerated PGP Public Key file
List of Byte
With Integrity CheckAdds a key string to the front of the signed files encryption text for validating the plain text portion to ensure file contents are secureBoolean

Outputs

PropertyDescriptionData Type
OutputOutputs a signed and encrypted fileString

Example Inputs and Outputs

AlgorithmBinaryDataInternal File LabelOutput File NamePrivate KeyPrivate Key PasswordPublic KeyWith Integrity CheckOutput
NullFalseexample.txtSigned FileexampleSigned.txtpriv.asccatchpub.ascFalseEXCEPTION MESSAGE
Sha1Falsesample.txtfactoid filesigned.txtpriv.asc
steerpub.asc
True

Id: "597426c4-a32d-4ac2-8e4f-7382b85874e0",FileName: "signed.txt",Length: 663,FileType: ".txt"

DoubleShaTrueNullNew FileNewsigned.txtpriv.asc
beginspub.asc
False

EXCEPTION MESSAGE

MD2Falsesample.txtNullNewSample.txtpriv.asc
catchpub.asc
TrueId: "42773b60-3afa-43ca-ada8-2274d4edb0f1",FileName: "Newsigned.txt",Length: 1675,FileType: ".txt"
Sha256Trueflowers.pngGroupEmptypriv.asc
catchpub.asc
False

Id: "6ad944f2-7da5-4097-9593-1fe53c1506aa",FileName: "",Length: 655,FileType: ""

Sha384Trueexample.docxfactsigned.docxNullsteerpub.asc
FalseEXCEPTION MESSAGE
MD5Falseexample.txtExample TextsignedExample.txtpriv.asc
Nullpub.asc
TrueEXCEPTION MESSAGE
Sha512Truesample.pdfApprovednewsample.pdfpriv.asc
passwordNullTrueEXCEPTION MESSAGE
Sha224FalseshowInfo.pdfFile Signedshowsign.pdfprivate.txtcatchpub.asc
FalseEXCEPTION MESSAGE
MD5FalsepartyList.xlsSigned FileconfirmList.xlspriv.asc
passwordpub.asc
EmptyEXCEPTION MESSAGE


Common Errors

Parameter 'binary' of 'SignAndEcryptFile' can not be null 

If the Binary field is null or empty, the step will cause an error.

To correct this, set the input mapping for the Binary field to Constant.

Exception Message:

Exception Stack Trace: DecisionsFramework.BusinessRuleException: [BusinessRule] Parameter 'binary' of 'SignAndEcryptFile' can not be null at DecisionsFramework.Design.Flow.CoreSteps.InvokeMethodUtility.ThrowErrorIfNullIsNotAllowed(MethodInfo methodInfo, Object[] parameterValues, String errorMessage
 at DecisionsFramework.Design.Flow.StepImplementations.InvokeMethodStep.Run(StepStartData data
 at DecisionsFramework.Design.Flow.FlowStep.RunStepInternal(String flowTrackingID, String stepTrackingID, KeyValuePairDataStructure[] stepRunDataValues, AbstractFlowTrackingData trackingData
 at DecisionsFramework.Design.Flow.FlowStep.Start(String flowTrackingID, String stepTrackingID, FlowStateData data, AbstractFlowTrackingData trackingData, RunningStepData currentStepData)

Buffer cannot be null 

If the Data, Private Key, or Public Key fields are null or empty, the step will cause an error.

To correct this, ensure that each field's value is uploaded or mapped correctly with the appropriate file.

Exception Message:

Exception Stack Trace: DecisionsFramework.Design.Flow.ErrorRunningFlowStep: Error running step Sign and Encrypt File 1[SignAndEcryptFile] in flow [Flow 2]: Exception invoking method SignAndEcryptFile on class PGPSteps
 ---> DecisionsFramework.LoggedException: Exception invoking method SignAndEcryptFile on class PGPSteps
 ---> System.ArgumentNullException: Buffer cannot be null. (Parameter 'buffer'
 at System.IO.MemoryStream..ctor(Byte[] buffer
 at Decsisions.PGP.Steps.PGPSteps.SignAndEcryptFile(String internalFileLabel, Byte[] publicKey, Byte[] privateKey, String privateKeyPassword, Byte[] data, Boolean binary, String outputFileName, Boolean withIntegrityCheck, HashAlgorithmTag algorithm)
   --- End of inner exception stack trace --- at DecisionsFramework.Design.Flow.StepImplementations.InvokeMethodStep.Run(StepStartData data
 at DecisionsFramework.Design.Flow.FlowStep.RunStepInternal(String flowTrackingID, String stepTrackingID, KeyValuePairDataStructure[] stepRunDataValues, AbstractFlowTrackingData trackingData
 at DecisionsFramework.Design.Flow.FlowStep.Start(String flowTrackingID, String stepTrackingID, FlowStateData data, AbstractFlowTrackingData trackingData, RunningStepData currentStepData)
   --- End of inner exception stack trace ---

Object reference not set to an instance of an object. 

If the Private Key Password field is null or empty, the step will cause an error.

To correct this, ensure that the correct password is entered.

Exception Message:

Exception Stack Trace: DecisionsFramework.Design.Flow.ErrorRunningFlowStep: Error running step Sign and Encrypt File 1[SignAndEcryptFile] in flow [Flow 2]: Exception invoking method SignAndEcryptFile on class PGPSteps
 ---> DecisionsFramework.LoggedException: Exception invoking method SignAndEcryptFile on class PGPSteps
 ---> System.NullReferenceException: Object reference not set to an instance of an object. 
at Decsisions.PGP.Steps.Processor.GetPrivateKey(PgpSecretKey secretKey, String password
 at Decsisions.PGP.Steps.BouncyCastleProcessor.SignAndEncryptStream(Stream inputStream, String internalFileLabel, Stream privateKeyStream, String privateKeyPassword, String s1, Stream[] publicKeyStreams, Stream encryptedStream, DateTime date, Boolean armorAscii, Boolean withIntegrityCheck, HashAlgorithmTag hashAlgorithm
 at Decsisions.PGP.Steps.PGPSteps.SignAndEcryptFile(String internalFileLabel, Byte[] publicKey, Byte[] privateKey, String privateKeyPassword, Byte[] data, Boolean binary, String outputFileName, Boolean withIntegrityCheck, HashAlgorithmTag algorithm)
   --- End of inner exception stack trace --- at DecisionsFramework.Design.Flow.StepImplementations.InvokeMethodStep.Run(StepStartData data
 at DecisionsFramework.Design.Flow.FlowStep.RunStepInternal(String flowTrackingID, String stepTrackingID, KeyValuePairDataStructure[] stepRunDataValues, AbstractFlowTrackingData trackingData
 at DecisionsFramework.Design.Flow.FlowStep.Start(String flowTrackingID, String stepTrackingID, FlowStateData data, AbstractFlowTrackingData trackingData, RunningStepData currentStepData)
   --- End of inner exception stack trace ---

[BusinessRule] Parameter 'withIntegrityCheck' of 'SignAndEncryptFile' can not be null 

If the With Integrity Check field is null or empty, the step will cause an error.

To correct this, set the input mapping of the With Integrity Check to Constant.

Exception Message:

Exception Stack Trace: DecisionsFramework.BusinessRuleException: [BusinessRule] Parameter 'withIntegrityCheck' of 'SignAndEcryptFile' can not be null 
at DecisionsFramework.Design.Flow.CoreSteps.InvokeMethodUtility.ThrowErrorIfNullIsNotAllowed(MethodInfo methodInfo, Object[] parameterValues, String errorMessage
 at DecisionsFramework.Design.Flow.StepImplementations.InvokeMethodStep.Run(StepStartData data
 at DecisionsFramework.Design.Flow.FlowStep.RunStepInternal(String flowTrackingID, String stepTrackingID, KeyValuePairDataStructure[] stepRunDataValues, AbstractFlowTrackingData trackingData
 at DecisionsFramework.Design.Flow.FlowStep.Start(String flowTrackingID, String stepTrackingID, FlowStateData data, AbstractFlowTrackingData trackingData, RunningStepData currentStepData)

unknown object in stream 32 

If the file uploaded or mapped to the Private Key or Public Key fields is not the correct file type (i.e., a .txt or .pdf file), the step will cause an error.

To correct this, ensure that the appropriate PGP Private Key or Public Key file is uploaded or mapped to the respective field. 

Exception Message:

Exception Stack Trace: DecisionsFramework.Design.Flow.ErrorRunningFlowStep: Error running step Sign and Encrypt File 1[SignAndEcryptFile] in flow [Flow 2]: Exception invoking method SignAndEcryptFile on class PGPSteps
 ---> DecisionsFramework.LoggedException: Exception invoking method SignAndEcryptFile on class PGPSteps
 ---> System.IO.IOException: unknown object in stream 32 at Org.BouncyCastle.Bcpg.OpenPgp.PgpObjectFactory.NextPgpObject(
 at Org.BouncyCastle.Bcpg.OpenPgp.PgpObjectFactory.AllPgpObjects(
 at Decsisions.PGP.Steps.Processor.GetSecretKeyRingBundle(Stream inputStream
 at Decsisions.PGP.Steps.Processor.GetPgpSecretKey(Stream stream
 at Decsisions.PGP.Steps.BouncyCastleProcessor.SignAndEncryptStream(Stream inputStream, String internalFileLabel, Stream privateKeyStream, String privateKeyPassword, String s1, Stream[] publicKeyStreams, Stream encryptedStream, DateTime date, Boolean armorAscii, Boolean withIntegrityCheck, HashAlgorithmTag hashAlgorithm
 at Decsisions.PGP.Steps.PGPSteps.SignAndEcryptFile(String internalFileLabel, Byte[] publicKey, Byte[] privateKey, String privateKeyPassword, Byte[] data, Boolean binary, String outputFileName, Boolean withIntegrityCheck, HashAlgorithmTag algorithm)
   --- End of inner exception stack trace --- at DecisionsFramework.Design.Flow.StepImplementations.InvokeMethodStep.Run(StepStartData data
 at DecisionsFramework.Design.Flow.FlowStep.RunStepInternal(String flowTrackingID, String stepTrackingID, KeyValuePairDataStructure[] stepRunDataValues, AbstractFlowTrackingData trackingData
 at DecisionsFramework.Design.Flow.FlowStep.Start(String flowTrackingID, String stepTrackingID, FlowStateData data, AbstractFlowTrackingData trackingData, RunningStepData currentStepData)
   --- End of inner exception stack trace ---

Related Information

Documentation:
PGP Module

Forum Posts:
Email Encrypt / Decrypt With PGP Module
Error While Encrypting A File Using PGP
PGP Issues With Decrypting Using Private Key


Was this article helpful?

What's Next