w3c / w3c/webcrypto

AES-CBC without PKCS#7 padding for 16-byte aligned blocks

Open
#295 6 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
294
Forks
78
PR merge metrics
No merged PRs in 30d

Description

It looks like the current implementations in Chrome (95) and Safari (15) add 16 bytes of padding to already 16-byte aligned blocks prior to encryption (and expect the same when decrypting), and it appears to be correct according to the WebCrypto spec and https://datatracker.ietf.org/doc/html/rfc2315#section-10.3 it is referring.

However this is not compatible with ISO/IEC 23001-7 spec (aka Common Encryption) which doesn't allow any sort of padding whatsoever, all the AES-CBC operations are performed on blocks of size multiple of 16 bytes ("tail" bytes are passed unencrypted). The problem is that ISO/IEC 23001-7 is the base of all the DRM protection frameworks these days and AES-CBC is the only mode which makes Apple, Google, MS and DRM hardware vendors happy at the same time - it answers the question "what's the use case?":
https://lists.w3.org/Archives/Public/public-webcrypto-comments/2014Jun/0006.html

Btw WebCrypto's AES-CTR is fully compatible with ISO/IEC 23001-7, I was able to decrypt DRM-protected data with WebCrypto as long as it was AES-CTR, but handling CBC in a compatible way is plain impossible at the moment.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the WebCrypto specification's AES-CBC behavior and the linked RFC 2315 and ISO/IEC 23001-7 references. Compare their padding requirements and determine what API or specification change could provide compatibility; done means an agreed resolution for CBC handling.

Written by the indexing model from the issue text.

Assessment

Domain
api, cryptography
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.