golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.49k stars 17.6k forks source link

proposal: crypto/tls: add support for AES-CCM #27484

Open igolaizola opened 6 years ago

igolaizola commented 6 years ago

Hi! I am working in a project that requires AES-CCM cipher suite within TLS. I know that crypto/tls aims to support a limited safe subset of TLS. But since TLS 1.3 will only support the following cipher suites:

TLS_AES_128_GCM_SHA256 TLS_AES_256_GCM_SHA384 TLS_CHACHA20_POLY1305_SHA256 TLS_AES_128_CCM_SHA256 TLS_AES_128_CCM_8_SHA256

Reducing that list from 5 to only 3 choices seems pretty unfair.

I've seen some working golang AES-CCM implementations around github. Is there any specific reason why this cipher suite is not included?

Thanks!

Update: Another option could be to port the code from BoringSSL: https://github.com/google/boringssl/blob/master/crypto/cipher_extra/e_aesccm.c

/cc @FiloSottile @agl

FiloSottile commented 6 years ago

I don't believe we need AES-CCM. Ideally, we would only support one or two ciphersuites at a time, and I intend to emulate BoringSSL in not exposing any choice of ciphersuite in TLS 1.3, selecting the fastest between AES-GCM and ChaCha20 based on hardware support (or the one preferred by the client based on PreferServerCipherSuites). As long as the default is fast and secure, the end user shouldn't have to make a decision on cipher block modes.

I don't think there's a fairness argument to the number of choices, as long as most users are served by the available options. If you believe I'm missing a concrete use case for AES-CCM that's not covered by the other supported ciphersuites, please do follow up.

igolaizola commented 6 years ago

@FiloSottile the missing use case is quite simple: IoT device where using AES-CCM is faster/consumes less than AES-GCM and connecting through TLS to a cloud service implemented in golang.

glerchundi commented 6 years ago

I disagree @FiloSottile, most of the current battery-powered IoT devices doesn't have accelerated Galois mode of authentication which force us to use the software based ChaCha20-Poly1305.

That is a deal breaker for lots of devices already deployed where only hardware-accelerated AES is available. In our internal tests AES (HW), CCM (SW) is much more efficient (for a battery draining POV) than ChaCha20-Poly1305. Although there are already known flaws in AES-CCM combo I think it's worth implementing it.

Perhaps you can tell me why does IETF board included this cipher combo in TLS 1.3?

Can you reconsider this?

FiloSottile commented 6 years ago

I'm reopening this to see how popular this request is and to look more into the AES-CCM mode (what "known flaws" are you referring to?), but 1) crypto/tls takes a minimalist approach, and 2) carrying a performant AES-CCM would probably cause us to carry extra assembly implementations, which is a deal-breaker at least for now.

glerchundi commented 6 years ago

Thanks at least for thinking it twice.

  1. More than flaws, they are probable attacks:
  2. Why not just a pure-go implementation for the initial phase?
Dirbaio commented 6 years ago

I'm also finding myself in need of an AES-CCM implementation to communicate with an IoT device (Custom protocol, not TLS, though). And again, AES-CCM is the cipher of choice due to having hardware-accelerated AES.

So +1 on this.

(Also, the attacks linked above are power analysis attacks against hardware implementations. They're not cryptanalytic attacks against the algorithm itself. I don't believe they are reasons to not include CCM)

igolaizola commented 5 years ago

In case this proposal gets approved there is a valid CCM implementation at https://github.com/bocajim/dtls

I have submitted a MR (https://github.com/golang/crypto/pull/62) but it was denied because I am not the author of the code and because this proposal must be approved first.

/cc @bocajim @jimwert

glerchundi commented 5 years ago

Friendly ping, including also to (maybe) interested parties (@agl @bradfitz)

FiloSottile commented 5 years ago

The cost of carrying assembly implementations has unfortunately not improved, so this is still on hold for the same reasons here https://github.com/golang/go/issues/27484#issuecomment-421078808.

igolaizola commented 5 years ago

What about an AES-CCM implementation without assembly optimizations? This will allow IoT devices with AES acceleration to connect to a server running golang code even if the server is not optimized. The bottleneck here will be probably the IoT device, not the server anyway.

daenney commented 5 years ago

I second @igolaizola proposal. CCM is largely useful for communicating with IoT devices/gateways, so not having assembly optimised implementations is unlikely to be a source of problems. It would be nice to not have this requirement hold it back but land CCM support so that when the need arises we can improve by adding the assembly in future versions.

I'm currently looking at lifting bocajim/dtls CCM implementation into pions/dtls so we can end up with one DTLS library supporting all use cases, but it would be great to have this in stdlib instead and avoid needing to carry that code.

jimwert commented 5 years ago

I also agree with the proposal, CCM in the standard library would be a big improvement.


From: Daniele Sluijters notifications@github.com Sent: Tuesday, March 26, 2019 6:12 AM To: golang/go Cc: Jim Wert; Mention Subject: Re: [golang/go] proposal: crypto/tls: add support for AES-CCM (#27484)

I second @igolaizolahttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Figolaizola&data=02%7C01%7CJim.Wert%40telit.com%7C8a7f8b5f4aa548ac1e5108d6b1d39fba%7C15d9cfdc338445c582dc3426a208a45c%7C1%7C0%7C636891919806404170&sdata=QiTsP4ceBqaBVT6Jepn6qgrlMZynHiGGzKzWZ4Qa5EI%3D&reserved=0 proposal. CCM is largely useful for communicating IoT devices/gateways, so not having server-side assembly optimised implementations is unlikely to be a source of problems. It would be nice to not have this requirement hold it back but land CCM support so that when the need arises we can improve by adding the assembly in future versions.

I'm currently looking at lifting bocajim/dtlshttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fbocajim%2Fdtls&data=02%7C01%7CJim.Wert%40telit.com%7C8a7f8b5f4aa548ac1e5108d6b1d39fba%7C15d9cfdc338445c582dc3426a208a45c%7C1%7C0%7C636891919806414179&sdata=Qd5HutXOxcgxTLG4a1cxMpDhsN1FnUUu7ijiag%2Bfr9w%3D&reserved=0 CCM implementation into pions/dtlshttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpions%2Fdtls&data=02%7C01%7CJim.Wert%40telit.com%7C8a7f8b5f4aa548ac1e5108d6b1d39fba%7C15d9cfdc338445c582dc3426a208a45c%7C1%7C0%7C636891919806414179&sdata=EE8ebqkJHyXqebJfPSUUVpf9hRjt4%2FvDTCdX2b3S4kg%3D&reserved=0 so we can end up with one DTLS library supporting all use cases, but it would be great to have this in stdlib instead and avoid needing to carry that code.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fgolang%2Fgo%2Fissues%2F27484%23issuecomment-476557184&data=02%7C01%7CJim.Wert%40telit.com%7C8a7f8b5f4aa548ac1e5108d6b1d39fba%7C15d9cfdc338445c582dc3426a208a45c%7C1%7C0%7C636891919806424183&sdata=5yjV0FVsmNXDa84exq8OiKU%2F4q%2FOMaHwLPXgz9oiZgs%3D&reserved=0, or mute the threadhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFS1CeJmcFZDsN73wlEGjwW7p8lWY42tks5vafKngaJpZM4WYjtD&data=02%7C01%7CJim.Wert%40telit.com%7C8a7f8b5f4aa548ac1e5108d6b1d39fba%7C15d9cfdc338445c582dc3426a208a45c%7C1%7C0%7C636891919806424183&sdata=E5vM8lciMsBHtyPd1zJD7F7kl11f8tQlnk8%2BqPDPQ3Y%3D&reserved=0.

newmanifold commented 4 years ago

Is the any progress going on? as above comments mentions it will be helpful if is CCM implementation (no necessarily hardware accelerated) makes into standard library, i am also in need for CCM to communicate with IoT gateway.

daenney commented 4 years ago

@newmanifold If it can help you, feel free to take a look at https://github.com/pion/dtls/tree/master/internal/crypto/ccm

daenney commented 3 years ago

@FiloSottile Can we get you to take another look at this, please? We're not looking to add assembly, which seems to be the biggest concern that was brought up previously. People are just looking for a pure-Go additional as a first step to stdlib.

greg-szabo commented 1 year ago

I'm testing Yubico YubiHSM's import/export functionality that uses AES-CCM for wrapping private keys. I thought I'll whip up a quick encoder/decoder in Go to prove that the algorithm works as intended. (It doesn't, that's why I wanted to confirm using software.)

Apparently, I'm going to "whip up" a "quick" encoder/decoder in C, using OpenSSL libraries. :(

daenney commented 1 year ago

@ianlancetaylor My apologies for the ping, but the "on-hold" label was added to this over 4 years ago. So even though it's open it's essentially in limbo, based initially on the belief that this would mean carrying assembly implementations which at the time was deemed a deal breaker.

I think it would be nice to re-evaluate that and if necessary close it to at least put this to bed. I don't think the assembly implementations are required, at least not as a first step to adding CCM support as has been pointed out by a number of people.

rsc commented 1 year ago

The discussion above from 2018 sounds like we don't want to add this because we want a limited number of well-tested algorithms in crypto/tls and not all possible algorithms. There was some question about whether AES-CCM is needed on certain devices, which might make it more important. I still don't quite see that evidence here though. Why is CCM needed?

It sounds like AES-CCM may be preferred on IoT devices over AES-GCM because it is less computationally expensive and uses less power. On the other hand, https://github.com/golang/go/issues/27484#issuecomment-423070538 suggests there may be attacks against it, which is one reason we'd leave it out. It's unclear how to balance those.

https://github.com/golang/go/issues/27484#issuecomment-1463848946 about YubiKey wrapping of private keys does not seem like it would use crypto/tls, only AES-CCM. That can be obtained from a third-party library easily. What's not easy is integrating it into crypto/tls.

@FiloSottile, @rolandshoemaker, @golang/security, thoughts?

rolandshoemaker commented 1 year ago

If, due to IOT, CCM is actually becoming somewhat widespread, it seems reasonable to reconsider our stance on pulling in support for crypto/tls (other use cases are less interesting in terms of standard library support). I'd like to see some data, if anyone has any, on actual usage.

Looking at the suggested attacks, those are both reliant on power side channel analysis, but I don't think we've ever considered those types of attacks within our threat model.

I think our main stumbling block here is that, given the current structure of the AES implementations, in order to get an optimized implementation we'd need a giant new hunk of assembly as we've not split out the common AES core from the other cipher modes. Perhaps we'd accept a pure-go implementation, for now, and once we clean up the AES assembly we could look towards optimizing, but that would mean it would be ~slow for a while.

daenney commented 1 year ago

Currently we carry an AES-CCM implementation in pion/dtls as it's required for CoAP. Specifically TLS_PSK_WITH_AES_128_CCM_8 and TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 are mandated. In practice it means anyone deploying IoT devices using CoAP would have a need for it. At least one residential product uses this that I'm aware of, which is the IKEA Tradfri Gateway (and the reason I added AES-CCM support to Pion). I don't have figures on how many other devices are using CoAP though. Though CoAP runs over UDP, hence dtls, it may give you a sense of real life deployments. Perhaps a go-coap developer like @jkralik might have some numbers.

As far as I know, WPA2's CCMP mode is also based on AES-CCM. Zigbee uses a derivative called CCM* to allow for encryption only. In practice AES-CCM is in use all around you, people generally just don't realise 🙂.

For Pion we don't carry optimised assembly implementations, because they're hard to maintain and none of the maintainers at the time felt comfortable taking that on. We've considered doing so in the past by leveraging Avo. We've had a "performance" issue in the past where CCM ended up getting selected over other more performant ciphers when available. This was mostly a bug in us advertising CCM support by default and accidentally prioritising it. This is something we changed to be opt-in (as in you have to explicitly enable CCM ciphers). Aside from that one case, we've never had someone raise issues with the AES-CCM performance in the past 4-5 years so thus far we've only ever carried a pure-go implementation.

yackermann commented 1 year ago

+1 from FIDO Alliance regarding IoT. Our FDO protocol supports CCM, and we have vendors that do use it. It's a pain that it's not a core crypto suite.

daenney commented 1 year ago

One other case to add to the list; when exporting/importing keys using wrapped keys from/to an HSM, AES-CCM is used in some case for the wrapping key. YubiHSM does it that way for example.