4 Replies
      Latest reply on Apr 14, 2019 12:06 PM by Claude31
      nlittle8 Level 1 Level 1 (0 points)

        Hello,

         

        I am currently getting an error, "too small input packet from ECIES decrypt" in my iOS app under development.

         

        I have two scenarios, on that works and one that doesn't work.  I'm trying to figure out why the one doesn't work.

         

        Scenario A - working:

         

        One device, multiple accounts:

         

        User creates account A -

        - Create elliptic curve key with kSecAttrKeyTypeECSECPrimeRandom

        - Ecrypt data with eciesEncryptionCofactorVariableIVX963SHA256AESGCM

        - send encrypted data X to server

        - user posts private key to 3rd party server

        - logout

         

        User creates accout B, same device same app

        - User B searches for user a.

        - User B retreives private key from 3rd party

        - User B imports private key into keychain using keyAttrs including kSecAttrKeyTypeECSECPrimeRandom

        - User B downloads encrypted data X from server, decryption successful

         

         

        Scenario B - not working:

         

        User creates account A -

        - Create elliptic curve key with kSecAttrKeyTypeECSECPrimeRandom

        - Ecrypt data with eciesEncryptionCofactorVariableIVX963SHA256AESGCM

        - send encrypted data X to server

        - user posts private key to 3rd party server

        - logout

         

        **USER DELETES APP AND REINSTALLS

         

        User creates accout B, same device same app

        - User B searches for user a.

        - User B retreives private key from 3rd party

        - User B imports private key into keychain using keyAttrs including kSecAttrKeyTypeECSECPrimeRandom

        - User B downloads encrypted data X from server -DECRYPT FAILS
        - ERROR - Error Domain=NSOSStatusErrorDomain Code=-50 "<SecKeyRef curve type: kSecECCurveSecp256r1, algorithm id: 3, key type: ECPrivateKey, version: 4, block size: 256 bits, addr: 0x108d23620>: too small input packet for ECIES decrypt"

        Would greatly apprecaite any support.  I am at a loss of why this isn't working and have been baging my head against the wall for 14+ hours.  I've double checked key import attrs, encryption varibles, etc.  I'm at a loss of what to do.

         

        Thanks,

        Nick