IPWorks Encrypt 2020 Python Edition

Questions / Feedback?

add_header_param Method

Adds additional header parameters.

Syntax

def add_header_param(name: str, value: str, data_type: int) -> None: ...

Remarks

This method is used to add additional header parameters before calling encrypt.

The Name and Value parameters define the name and value of the parameter respectively. The DataType parameter specifies the JSON data type of the value. Possible values for DataType are:

  • 0 (Object)
  • 1 (Array)
  • 2 (String)
  • 3 (Number)
  • 4 (Bool)
  • 5 (Null)
To add additional parameters to the JOSE header use this method. For instance to create this header:


{
	"alg": "A256GCMKW",
	"crit": [
		"exp"
	],
	"enc": "A128CBC-HS256",
	"exp": 12345687,
	"iv": "SFZ9o0KKN8qF8yod",
	"tag": "tREHGKuViLo7s3QpRTulkg",
	"type": "JWT"
}

The following code can be used:


Jwe jwe = new Jwe();
jwe.EncryptionAlgorithm = JweEncryptionAlgorithms.eaA256GCMKW;
jwe.KeyB = key;
jwe.AddHeaderParam("type", "JWT", 2);
jwe.AddHeaderParam("crit", "[\"exp\"]", 1);
jwe.AddHeaderParam("exp", "12345687", 3);
jwe.InputMessage = "test";
jwe.Encrypt();
string encryptedData = jwe.OutputMessage;

Note: When calling encrypt the class will automatically add headers based on the selected encryption_algorithm and other properties that may be set.

Parameters Automatically Set:

Header ParamProperty
alg encryption_algorithm
enc content_encryption_algorithm
kid key_id
zip CompressionAlgorithm
p2c PBES2Count (PBES Algorithms Only)
apu PartyUInfo (ECDH Algorithms Only)
apv PartyVInfo (ECDH Algorithms Only)
iv N/A - Automatically Generated (AES Algorithms Only)
tag N/A - Automatically Generated (AES Algorithms Only)
p2s N/A - Automatically Generated (PBES Algorithms Only)
epk N/A - Automatically Generated (ECDH Algorithms Only)

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Encrypt 2020 Python Edition - Version 20.0 [Build 8155]