AES encryption in conzept 16

In addition to the previously announced signature functions (see Signieren mit CONZEPT 16), the procedures will be expanded to include encryption and decryption commands, which primarily enable the exchange of encrypted data with other applications. The symmetric cryptographic method AES (Advanced Encryption Standard) is used for this purpose.


In symmetric procedures, the same key is used for both encryption and decryption. AES is the successor to DES (Data Encryption Standard), whereby the data is processed in data blocks. Each data block is always 128 bits long; larger amounts of data are divided into a corresponding number of blocks. If the length of the data is not exactly 128 bits or a multiple thereof, it is padded using PKCS#7 padding.

A block is a two-dimensional byte array, which is defined with 4 columns and 4 rows in AES. Accordingly, the block size is 16 bytes = 128 bits. Several rounds (repetitions) of certain operations are then carried out on the data of a block using the key, resulting in the encrypted block at the end.

The length of the key is independent of the block length and can be 128, 192 or 256 bits. The designations AES-128, AES-192 and AES-256 therefore refer to the length of the key used. A longer key length means greater data security, but also a slightly higher computing effort.

With block encryption, it is important that the ciphertext cannot be used to draw any conclusions about the key (confusion) and that even changing a tiny part of the message to be encrypted changes the entire ciphertext in an unpredictable way (diffusion). For this purpose, AES is used in conjunction with a so-called operating mode, which defines how larger data volumes with multiple blocks are to be handled.

The following operating modes are currently available:

  • Cipher-block chaining (CBC)
  • Output feedback (OFB)
  • Galois/Counter Mode (GCM)

Another security factor is the initialization vector (IV). The IV is intended to prevent the ciphertext from always being the same when using the same message and the same key. Otherwise, it would be possible to use cryptanalysis to draw conclusions about the key used (for example, to recognize certain groups of words). The IV is generated randomly and should not be used more than once. The length of the IV is identical to the block length used, i.e. 128 bits. Since the IV itself is not sufficient for decryption, it does not have to be secret.

Encrypting

The MemEncrypt() function is used for encryption and is structured as follows:

MemEncrypt(
      MemMsg        : handle; // Plain text / Ciphertext
      Options       : int;    // Options
      Key           : alpha;  // Key
      IV            : alpha;  // Initialization vector
  opt Pos           : int;    // Plain text position
  opt Len           : int;    // Plain text length
  opt MemDst        : handle; // Cipher
  opt PosDst        : int;    // Cipher position
  opt MemKey        : handle; // Binary key
  opt MemIV         : handle; // Binary IV
  opt MemTag        : handle; // GCM authentication tag
)
: int                         // Error value
Arguments
  • MemMsg
    A memory object is passed in MemMsg, which contains the message that is to be encrypted. If no target object is specified in MemDst, MemMsg is overwritten with the ciphertext after successful encryption.
  • Options
    The Options parameter is made up of the following 4 areas: Encryption algorithm, Operating mode, Key coding and IV coding. The encryption algorithms AES-128 (_MemCipherAES128), AES-192 (_MemCipherAES192) and AES-256 (_MemCipherAES256) are provided at the beginning. The constants _MemCipherModeCBC, _MemCipherModeOFB and _MemCipherModeGCM are available for the modes already mentioned above.The Key encoding area specifies whether the key in Key is hex (_MemKeyHex) or base64 encoded (_MemKeyBase64). The key can also be binary (_MemKeyMem). If this constant is specified, a memory object containing the key must also be transferred in MemKey.

    The same applies for the IV coding area as for the Key coding. The coding of the initialization vector is specified here and the constants _MemIVHex, _MemIVBase64 and _MemIVMem are available. For _MemIVMem, a memory object with the initialization vector in MemIV must be transferred.

  • Key / IV
    The key and the initialization vector are transferred in Key and IV. When using _MemKeyMem / _MemIVMem, Key / IV is not evaluated.
  • Pos / Len
    The position and length of the plain text in the memory object can be specified using Pos and Len.
  • MemDst / PosDst
    If a memory object is passed in MemDst, it contains the ciphertext after successful encryption. MPosDst can be used to specify the position at which the ciphertext is written in MemDst.
  • MemKey / MemIV
    contains the key / initialization vector and is only evaluated if the option _MemKeyMem / _MemIVMem is set.
  • MemTag
    A memory object must be specified here if GCM mode is used. After encryption, it contains a tag that is used for authentication.

Decryption

The function for decrypting is MemDecrypt() and has the following structure:

MemDecrypt(
      MemChf        : handle; // Plain text / Ciphertext
      Options       : int;    // Options
      Key           : alpha;  // Key
      IV            : alpha;  // Initialization vector
  opt Pos           : int;    // Plain text position
  opt Len           : int;    // Plain text length
  opt MemDst        : handle; // Cipher
  opt PosDst        : int;    // Cipher position
  opt MemKey        : handle; // Binary key
  opt MemIV         : handle; // Binary IV
  opt MemTag        : handle; // GCM authentication tag
)
: int                         // Error value

The heads of the functions MemEncrypt() and MemDecrypt() are almost identical. The only difference between the functions is that MemDecrypt() expects a memory object in the first argument (MemChf) that contains the ciphertext to be decrypted. Furthermore, the authentication tag returned by MemEncrypt() is specified in the last argument.

Klicken Sie hier, um die Nutzungsbedingungen für unseren Blog zu lesen.

Leave a Reply

Your email address will not be published. Required fields are marked *

Leave the field below empty!

Requests, questions or feedback are welcome:

Terms of use of the comment function in the blog

1. General information

Vectorsoft AG (‘Provider’) provides a public blog for Internet users (‘Users’) on the vectorsoft.de website. The public blog is intended for the exchange of information and ideas. Users who participate with contributions and comments undertake to comply with the blog terms of use and are responsible for the accuracy, appropriateness and freedom from legal infringements of their contributions. By using the comment function in our blog, you accept these terms of use.

2. Netiquette

We ask you to refrain from personal attacks and provocations based on other opinions. Please argue objectively and maintain a constructive discussion culture. Your comment should always be related to the topic in question in order to avoid digressions into other topics. Posting the same comment or several similar comments more than once is not permitted.

3. Prohibition of illegal content

By submitting your comment, you confirm that you are not violating any copyrights or other rights of third parties. Inciting, racist statements, instructions for criminal offences and their glorification, depictions of violence, pornographic content and statements that violate personal rights are prohibited.

4. No advertising

The use of the comment function is not permitted for commercial or party-political purposes. Advertising contributions of any kind will be deleted immediately.

5. Details of the name

When entering your name, pay attention to the principles mentioned above.

6. Source references

If you intend to publish quotes or contributions from third parties, please indicate the respective sources and explain how they relate to the blog post.

7. Violation of the terms of use

Posts that violate this policy will be deleted immediately. If you notice any violations yourself, please send us the link to the comment in question by e-mail to . We expressly point out that we will exclude individual users in the event of repeated or serious violations of these terms of use.

As of: Sept. 2024

Get your Trial Version now!

Test yeet free of charge

IHRE EVALUIERUNGSLIZENZ - JETZT ANFORDERN!

TESTEN SIE DIE CONZEPT 16 VOLLVERSION - UNVERBINDLICH und KOSTENFREI

Subscribe to our newsletter

[cleverreach_signup]
WordPress Cookie Notice by Real Cookie Banner