Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6581549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:10:01+00:00 2026-05-25T16:10:01+00:00

I’m developing a USB bootloader for an embedded system and one of my requirements

  • 0

I’m developing a USB bootloader for an embedded system and one of my requirements is that data transmission over USB should be secure(bear with me, I’m new to encryption). I’ve decided to encrypt the data with AES, but the data isn’t always in nice 16 bytes chunks so I need to pad it. It seems like PKCS7 is the standard method to use when padding data for AES (not to mention it’s pretty simple), so I think I’d like to use it.

The problem I have is, I can’t understand how PKCS7 doesn’t lose data. Let me illustrate with an example:

Imagine a 16 byte buffer to be encrypted whose last character is 0x01. Now imagine a 15 byte buffer to be encrypted…this buffer will be padded with 0x01. After both buffers are encrypted, transmitted, received, and decrypted, how does the receiver tell the difference between the buffer with padding and the buffer whose actual last character is 0x01?

I feel like I’m missing something in the PKCS7 spec. Can anyone help me understand? Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:10:01+00:00Added an answer on May 25, 2026 at 4:10 pm

    Yes, you are missing a point. If the data length is a full multiple of the block length (i.e. a multiple of 16 bytes for AES), the padding will append an additional full block (of 0x10 or 16) instead of nothing.

    So, we can always recover the length of the padding from the padding itself, since there is no “length 0 padding”.

    On the downside, the encrypted data is always bigger than the plain text, by at most a full block.

    (Similar padding is done for most hash functions, like SHA-1, before the actual hashing processing, so the blocked input to the actual hashing is collision-free – in some cases even a bit more than a full block is appended, since the actually hashed data ends with the original data length).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I
I'm trying to create an if statement in PHP that prevents a single post
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.