{
  "synLogic": "unsigned char* $ret \u003d $api($1, $2, $3, $4, $5, $6, $7, $8, $9);",
  "help": "The ns_aes_decrypt function is used to decrypt any input that has been encrypted using the AES encryption algorithm. It takes in the encrypted input as well as the key and initialization vector used for encryption and returns the decrypted plain text. If the decryption fails due to an incorrect key, initialization vector, or encryption algorithm.",
  "notes": "",
  "returns": "It return plain text, or NULL if the key does not decrypt the ciphertext because either the IVEC isn't the same as used for encryption or incorrect encryption algo is provided.",
  "arguments": "\u003ctable class\u003d\"newGuiTable\" style\u003d\"width:100%\" \u003e \u003ctr\u003e \u003cth\u003eArgument\u003c/th\u003e \u003cth\u003e Description \u003c/th\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003e Input \u003c/td\u003e \u003ctd\u003e The string to be decrypted \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003e Input length \u003c/td\u003e \u003ctd\u003e The length of the input data. \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003e Encryption Algorithm \u003c/td\u003e \u003ctd\u003e An encryption algorithm that can be aes-128-cbc, aes-192-cbc, aes-256-cbc, aes-128-ctr, aes-192-ctr, aes-256-ctr, ,aes-192-ecb. If not provided, aes_128_cbc will be used as the default. \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003e Encoding Options \u003c/td\u003e \u003ctd\u003e  To Specify whether Key, IVEC or output is Base64 encoded or use Key as passphrase use following Encoding flags accordingly :<br /><b>NS_AES_KEY_BASE64</b>:<br />This flag indicates that the AES key is base64-encoded. The AES key is a secret key used for encryption and decryption of data. When this flag is set, the input key is expected to be base64-encoded. If this flag is not set, the input key is assumed to be raw binary data.<br /> \u003cbr /\u003e<b>NS_AES_IVEC_BASE64</b>:<br />This flag indicates that the Initialization Vector (IVEC) for the AES encryption is base64-encoded. The IVEC is a fixed-size input to the encryption algorithm, which is combined with the secret key to generate a unique ciphertext. When this flag is set, the input IVEC is expected to be base64-encoded. If this flag is not set, the input IVEC is assumed to be raw binary data.<br /> \u003cbr /\u003e<b>NS_AES_OUTPUT_BASE64</b>:<br /> This flag indicates that the output of the AES encryption should be base64-encoded. The output of the encryption algorithm is usually raw binary data, but if this flag is set, it will be converted to base64-encoded data. This can be useful for transmission or storage of the encrypted data. <br /> \u003cbr /\u003e<b>NS_AES_KEY_AS_PASSPHRASE</b>:<br /> This flag indicates that the AES key should be used as a passphrase to generate the actual key used for encryption. This can be useful if the actual key is difficult to remember or if a user-friendly passphrase is preferred. When this flag is set, the input key is treated as a passphrase and is used to generate the actual key using a key derivation function. If this flag is not set, the input key is used directly as the actual key.<br /><br />To specify multiple combinations of the encoding options, use the bitwise OR operation to combine the respective bit flags. For example, to set the options NS_AES_KEY_BASE64 and NS_AES_OUTPUT_BASE64, you would use the expression NS_AES_KEY_BASE64 | NS_AES_OUTPUT_BASE64. The resulting value can then be passed as an argument in the appropriate API function to specify the desired encoding options. \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003e Key \u003c/td\u003e \u003ctd\u003e The text or binary string key to be use to decrypt input . It must be 16, 24, or 32 bytes long. \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003e Key length \u003c/td\u003e \u003ctd\u003e length of key \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003e Initialization Vector (IVEC) \u003c/td\u003e \u003ctd\u003e Initial state for a cryptographic algorithm. Values for \u003cbr /\u003e ECB (Electronic Code Book mode): not applicable, hence NULL should be passed\u003cbr /\u003eCTR (Galois/Counter Mode): can contain either text or binary value\u003cbr /\u003eCBC (Cipher Block Chaining): can contain either text or binary value \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003e IVEC length \u003c/td\u003e \u003ctd\u003e Length of Initialization \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003e Error Message \u003c/td\u003e \u003ctd\u003e Message to return in case of error/failure \u003c/td\u003e \u003c/tr\u003e \u003c/table\u003e",
  "parameterization": "",
  "name": "ns_aes_decrypt",
  "syntax": "unsigned char* ns_aes_decrypt(unsigned char *input, int input_len, int encryption_algo, int encoding_options, char *key , int key_len, char *initialization_vector, int ivec_len, char **err_msg)",
  "javaSyntax": "",
  "cEx": "flow()\n{\n  char *encrypted_text = \"U2FsdGVkX1/yb3qV7/ePMfMGUuW7mBH9fZZ0VpfnG1Y=\";\n  int encrypted_text_len = strlen(encrypted_text);\n  char *key = \"my_secret_key\";\n  int key_len = strlen(key);\n  char *iv = \"initialization_vector\";\n  int iv_len = strlen(iv);\n\n  char *err_msg = NULL;\n  unsigned char *decrypted_text = ns_aes_decrypt((unsigned char*)encrypted_text, encrypted_text_len, NS_AES_128_CBC, NS_AES_OUTPUT_BASE64, key, key_len, iv, iv_len, &err_msg);\n  if (decrypted_text != NULL) {\n    printf(\"Decrypted Text: %s\", decrypted_text);\n  } else {\n    printf(\"Error: %s\", err_msg);\n  }\n}",
  "javaEx": "",
  "insertStrC": "ns_aes_decrypt(unsigned char *input, int input_len, int encryption_algo, int encoding_options, char *key , int key_len, char *initialization_vector, int ivec_len, char **err_msg);",
  "insertStrJava": "",
  "description": "The ns_aes_decrypt function is used to decrypt any input that has been encrypted using the AES encryption algorithm. It takes in the encrypted input as well as the key and initialization vector used for encryption and returns the decrypted plain text. If the decryption fails due to an incorrect key, initialization vector, or encryption algorithm.",
  "component": [
    {
      "id": "$1",
      "type": "TEXT_VAR_PARAM",
      "label": "Input",
      "labelVarCheckbox": "Input text is a program variable",
      "value": "",
      "css": "p-grid p-align-center w-100-p",
      "title": "Enter Input",
      "placeHolder": "",
      "style": "",
      "isDisabled": "",
      "validate": {
        "inputType": "Text",
        "required": true
      }
    },
	{
      "id": "$2",
      "type": "TextField",
      "label": "Input Length",
      "labelVarCheckbox": "",
      "value": "0",
      "css": "p-grid p-align-center w-100-p",
      "title": "Enter Input Length",
      "placeHolder": "",
      "style": "",
      "isDisabled": "",
      "validate": {
        "inputType": "Number",
        "required": true,
        "min": "0",
        "max": "2147483647"
      }
    },
    {
	 "id":"$3",
	 "type":"Dropdown",
	 "label":"Encryption Algorithm",
	 "labelVarCheckbox":"",
	 "value":"AES_128_CBC",
	 "css":"p-grid p-align-center w-100-p",
	 "title":"Enter Encryption Algorithm",
	 "placeHolder":"Select Algorithm",
	 "style":"",
	 "isDisabled":"",
	 "list":[
		{
		   "label":"AES_128_CBC",
		   "value":"AES_128_CBC"
		},
		{
		   "label":"AES_192_CBC",
		   "value":"AES_192_CBC"
		},
		{
		   "label":"AES_256_CBC",
		   "value":"AES_256_CBC"
		},
		{
		   "label":"AES_128_CTR",
		   "value":"AES_128_CTR"
		},
		{
		   "label":"AES_192_CTR",
		   "value":"AES_192_CTR"
		},
		{
		   "label":"AES_256_CTR",
		   "value":"AES_256_CTR"
		},
		{
		   "label":"AES_192_ECB",
		   "value":"AES_192_ECB"
		}
	 ],
	 "validate":{
		"required":true
	 }
	},
	{
         "id":"$4",
         "type":"ENCODE_OPTIONS",
         "label":"Base64Encode Mode",
         "labelVarCheckbox":"",
         "value":"",
         "css":"p-grid p-align-center w-100-p",
         "title":"Enter Base64Encode Options",
         "placeHolder":"Select Base64Encode Mode",
         "style":"",
         "isDisabled":"",
           "validate":{
           "required":true
         }
        },
	{
      "id": "$5",
      "type": "TEXT_VAR_PARAM",
      "label": "Key",
      "labelVarCheckbox": "Input key is a program variable",
      "value": "",
      "css": "p-grid p-align-center w-100-p",
      "title": "Enter Key",
      "placeHolder": "",
      "style": "",
      "isDisabled": "",
      "validate": {
        "inputType": "Text",
        "required": true
      }
    },
	{
      "id": "$6",
      "type": "TextField",
      "label": "Key Length",
      "labelVarCheckbox": "",
      "value": "0",
      "css": "p-grid p-align-center w-100-p",
      "title": "Enter Key Length",
      "placeHolder": "",
      "style": "",
      "isDisabled": "",
      "validate": {
        "inputType": "Number",
        "required": true,
        "min": "0",
        "max": "2147483647"
      }
    },
	{
      "id": "$7",
      "type": "TEXT_VAR_PARAM",
      "label": "Initialization Vector (IVEC)",
      "labelVarCheckbox": "Initialization Vector is a program variable",
      "value": "",
      "css": "p-grid p-align-center w-100-p",
      "title": "Enter Initialization Vector",
      "placeHolder": "NULL",
      "style": "",
      "isDisabled": "",
      "validate": {
        "inputType": "Text",
        "required": false
      }
    },
	{
      "id": "$8",
      "type": "TextField",
      "label": "IVEC Length",
      "labelVarCheckbox": "",
      "value": "0",
      "css": "p-grid p-align-center w-100-p",
      "title": "Enter IVEC Length",
      "placeHolder": "",
      "style": "",
      "isDisabled": "",
      "validate": {
        "inputType": "Number",
        "required": true,
        "min": "0",
        "max": "2147483647"
      }
    },
	{
      "id": "$9",
      "type": "TextField",
      "label": "Error Message Buffer Pointer",
      "labelVarCheckbox": "",
      "value": "",
      "css": "p-grid p-align-center w-100-p",
      "title": "Enter Error Message",
      "placeHolder": "",
      "style": "",
      "quotes": false,
      "isDisabled": "",
      "validate": {
        "inputType": "Text",
        "required": true
      }
    },
    {
	  "id": "$ret",
	  "type": "TextField",
	  "label": "Return Variable (Pointer)",
	  "labelVarCheckbox": "",
	  "value": "",
	  "css": "p-grid p-align-center w-100-p",
	  "title": "First character must be Alpha.\r\nOther characters are Alpha, Numeric or Underscore",
	  "placeHolder": "",
	  "style": "",
	  "isDisabled": "",
	  "validate": {
		"inputType": "Text",
		"pattern": "^[a-zA-Z][a-zA-Z0-9_]{0,63}$",
		"method": "isValidVar(arg)",
		"required": false
	  }
	}
  ]
}
