4 Replies
      Latest reply on Oct 23, 2019 4:57 AM by newwbee
      newwbee Level 1 Level 1 (0 points)



        I would like to perform AES ECB (128 bits) encryption.


        I understand CryptoKit is available however I could only see AES GCM encryption.



        - Is it possible to do AES ECB encryption using CryptoKit ?

        - For older OS (example less than iOS 13 and macOS 10.15) what is the recommended framework / approach ?

        - Is there is any code sample / documentation / video on using the alternate framework ? (would help me as I am new to encryption)


        Note: I was hoping to use native frameworks as much as possible but was also scared of doing it on my own as I am new to it.


        Many thanks.

        • Re: AES ECB (128 bits)
          Claude31 Level 8 Level 8 (7,005 points)

          - Is it possible to do AES ECB encryption using CryptoKit ?

          Their documentation says it is possible.   h ttps://cryptoswift.io

          • Re: AES ECB (128 bits)
            eskimo Apple Staff Apple Staff (12,325 points)

            CryptoKit’s AES support only extends to AES-GCM.  This is not an accidental omission.  One of the goals of CryptoKit is to make it both easy to do the right thing and hard to do the wrong thing, and it’s very easy to do the wrong thing with ECB.  For a vivid illustration of this, see the classic ECB penguin image.

            Other folks have filed enhancement requests for other AES modes — for example, we have one for CBC (r. 51502441) — but I can’t see one for ECB.  You should feel free to file one yourself.  Please post your bug number, just for the record.

            In the meantime, you can do AES-ECB using CommonCrypto.  This is nowhere near as nice as CryptoKit, but it gets the job done.

            I am new to encryption

            Well, that’s a worry, given the fundamental problems associated with ECB.  Why are you using AES-ECB?

            Share and Enjoy

            Quinn “The Eskimo!”
            Apple Developer Relations, Developer Technical Support, Core OS/Hardware
            let myEmail = "eskimo" + "1" + "@apple.com"