Reader small image

You're reading from  Demystifying Cryptography with OpenSSL 3.0

Product typeBook
Published inOct 2022
PublisherPackt
ISBN-139781800560345
Edition1st Edition
Concepts
Right arrow
Author (1)
Alexei Khlebnikov
Alexei Khlebnikov
author image
Alexei Khlebnikov

Alexei Khlebnikov has more than 20 years of professional experience in IT, where he worked in different roles - software developer, system administrator, DevOps engineer, technical leader, architect and project manager. During those years Alexei worked with many technologies - Security, Artificial Intelligence, Web Development, Embedded, Mobile, and Robotics. Among other companies, Alexei worked in Opera Software on the famous Opera Internet browser. Alexei has always been interested in security. He was one of the maintainers of security-related Opera browser modules, responsible for cryptography, SSL/TLS and integration with OpenSSL. He was also a member of the Security Architects group, responsible for the security of the Opera browser. Now Alexei lives in Oslo, Norway, and works as a senior consultant for Bespoke AS. He is also the leader of the Architects group at his current employer.
Read more about Alexei Khlebnikov

Right arrow

Padding for block ciphers

In CBC mode, block ciphers encrypt plaintext data block by block – but what happens to the last plaintext block, which in most cases, is smaller than the block size? It cannot be encrypted as is, because a block cipher requires a complete data block as input. Thus, the last plaintext block is padded up to the block size.

OpenSSL can add padding automatically when finalizing encryption and remove it when finalizing decryption. This feature can be disabled – in such a case, the developer must pad and unpad the plaintext data himself.

Cryptographers invented different types of padding. For symmetric encryption, OpenSSL only supports Public Key Cryptography Standard number 7 padding (PKCS #7 padding), also known as PKCS7 padding, simply PKCS padding, or standard block padding. PKCS #7 padding consists of N bytes, each having the value N. For example, if the cipher block size is 16 bytes (128 bits) and the last block of plaintext is only 10...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Demystifying Cryptography with OpenSSL 3.0
Published in: Oct 2022Publisher: PacktISBN-13: 9781800560345

Author (1)

author image
Alexei Khlebnikov

Alexei Khlebnikov has more than 20 years of professional experience in IT, where he worked in different roles - software developer, system administrator, DevOps engineer, technical leader, architect and project manager. During those years Alexei worked with many technologies - Security, Artificial Intelligence, Web Development, Embedded, Mobile, and Robotics. Among other companies, Alexei worked in Opera Software on the famous Opera Internet browser. Alexei has always been interested in security. He was one of the maintainers of security-related Opera browser modules, responsible for cryptography, SSL/TLS and integration with OpenSSL. He was also a member of the Security Architects group, responsible for the security of the Opera browser. Now Alexei lives in Oslo, Norway, and works as a senior consultant for Bespoke AS. He is also the leader of the Architects group at his current employer.
Read more about Alexei Khlebnikov