Skip to content

Add support for CCM mode (Counter with CBC-MAC) #1141

Closed

Description

@wbolster

Currently cryptography does not support CCM (counter with CBC-MAC) mode (see http://en.wikipedia.org/wiki/CCM_mode).

Adding support for this mode was briefly mentioned/discussed in (now closed) issues/pull requests, e.g.

...but it doesn't seem to be tracked anywhere currently, hence this issue report.

Activity

  1. wbolster commented on Jun 16, 2014

    @wbolster
    ContributorAuthor

    Fwiw, PyCrypto 2.7 (not yet released I believe) supports CCM mode. (See https://gist.github.com/jbdatko/7425443 for an example.)

  2. reaperhulk commented on Jun 16, 2014

    @reaperhulk
    Member

    OpenSSL's CCM support has some really nasty limitations (and it's currently unclear to me what are limitations of the mode itself and what is OpenSSL specific). We'll look into it though.

  3. wbolster commented on Jun 20, 2014

    @wbolster
    ContributorAuthor

    What is the general opinion of the cryptography team about implementing crypto stuff in cryptography directly? (Most of it would be combining primitives provided by backends I guess.)

  4. lvh commented on Jun 20, 2014

    @lvh
    Member

    Simple enough things work fine, e.g. HKDF is clearly composed of other cryptographic primitives, but is a pure-Python implementation that lives in cryptography.

  5. reaperhulk commented on Jun 20, 2014

    @reaperhulk
    Member

    We'll probably make decisions on that on a case by case basis. My incomplete (personal) criteria for accepting it would be something like:

    • Is there a risk of side channel attacks?
    • Can it be implemented efficiently? (e.g. without causing a million copies)
    • Is there no acceptable implementation in the backend?
    • Is it complex?
  6. public commented on Jun 20, 2014

    @public
    Member

    Are there any significant users of CCM mode?

  7. wbolster commented on Jun 20, 2014

    @wbolster
    ContributorAuthor

    http://en.wikipedia.org/wiki/CCM_mode#Use states that "CCM mode is used in the IEEE 802.11i (as CCMP, an encryption algorithm for WPA2), IPSec, and TLS 1.2."

    (And I know it's also used in some embedded systems.)

    And of course Python should have it before Ruby has it ;-) ruby/ruby#569

  8. alex commented on Jun 20, 2014

    @alex
    Member

    It looks like this uses CCM Support within OpenSSL itself? That we can do
    easily enough; though of course in practice very few users will have access
    since it's not even in a released version of OpenSSL.

    On Fri, Jun 20, 2014 at 8:51 AM, Wouter Bolsterlee <[email protected]

    wrote:

    http://en.wikipedia.org/wiki/CCM_mode#Use states that "CCM mode is used
    in the IEEE 802.11i (as CCMP, an encryption algorithm for WPA2), IPSec, and
    TLS 1.2."

    (And I know it's also used in some embedded systems.)

    And of course Python should have it before Ruby has it ;-) ruby/ruby#569
    ruby/ruby#569

    —
    Reply to this email directly or view it on GitHub
    #1141 (comment).

    "I disapprove of what you say, but I will defend to the death your right to
    say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
    "The people's good is the highest law." -- Cicero
    GPG Key fingerprint: 125F 5C67 DFE9 4084

  9. reaperhulk commented on Jun 20, 2014

    @reaperhulk
    Member

    CCM is supported in OpenSSL 1.0.1, but the issue with it is that to prevent a variable-length attack on CBC-MAC you need to prepend the length of the message. This means you must know the length prior to encrypting a single block.

    It looks like some implementations (like Botan?) may not do this length prefixing, so interoperability in CCM may be problematic...

  10. alex commented on Jun 20, 2014

    @alex
    Member

    Ugh. Right.

    On Fri, Jun 20, 2014 at 9:02 AM, Paul Kehrer [email protected]
    wrote:

    CCM is supported in OpenSSL 1.0.1, but the issue with it is that to
    prevent a variable-length attack on CBC-MAC you need to prepend the length
    of the message. This means you must know the length prior to encrypting a
    single block.

    It looks like some implementations (like Botan?) may not do this length
    prefixing, so interoperability in CCM may be problematic...

    —
    Reply to this email directly or view it on GitHub
    #1141 (comment).

    "I disapprove of what you say, but I will defend to the death your right to
    say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
    "The people's good is the highest law." -- Cicero
    GPG Key fingerprint: 125F 5C67 DFE9 4084

  11. acv commented on Jun 20, 2014

    @acv

    SJCL defaults to CCM and it seems to have some popularity with the crypto
    in browser crowd. That seems more of a reason to not implement support
    however.

    Alex

    On Fri, Jun 20, 2014 at 11:39 AM, Alex Stapleton [email protected]
    wrote:

    Are there any significant users of CCM mode?

    —
    Reply to this email directly or view it on GitHub
    #1141 (comment).

  12. reaperhulk commented on Jun 4, 2016

    @reaperhulk
    Member

    We haven't seen any significant demand for this in 2 years and the API design tradeoffs required for CCM make me extremely reluctant to add support. Closing for now.

  13. chrysn commented on Mar 21, 2017

    @chrysn

    Please reconsider the "no significant demand" stance in the light of AES-CCM-64-64-128 being the mandatory-to-implement cipher in the upcoming OSCOAP specification for object security in communication with constrained devices. The Python implementation of it currently falls back to cffi-wrangling libssl itself (code), but I'd very much prefer to have a cryptography library provide that instead.

  14. reaperhulk commented on Mar 21, 2017

    @reaperhulk
    Member

    There has been some conversation in #2968 around building per-scheme AEAD interfaces. That would allow us to support CCM. Thanks for the link to a spec that is actively using CCM though, that's helpful!

  15. locked as resolved and limited conversation to collaborators on Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions