GithubHelp home page GithubHelp logo

Comments (4)

embhorn avatar embhorn commented on May 24, 2024

Hi @kenyiesnc

You are absolutely correct! The passed in key size should be used when setting the AES key. I've also updated the README to be more clear that the key size is in bits.

from wolfssl-examples.

kenyiesnc avatar kenyiesnc commented on May 24, 2024

Ran into errors when I pass in key size in bits... it seems like wc_AesSetKey requires key size to be passed in bytes? https://github.com/wolfSSL/wolfssl/blob/aa8e5a29d45f9327029311bfb1b8994feaa62368/wolfcrypt/src/aes.c#L90

from wolfssl-examples.

embhorn avatar embhorn commented on May 24, 2024

The wc_AesSetKey API does take size in bytes. The example passes in size in bits. I modified the example to convert the size in the SizeCheck function:

int SizeCheck(int *size)
{
    int ret = 0;

    /* Use key size values (size/8) */
    if (*size == 128) {
        *size = AES_128_KEY_SIZE;
    }
    else if (*size == 192) {
        *size = AES_192_KEY_SIZE;
    }
    else if (*size == 256) {
        *size = AES_256_KEY_SIZE;
    }
    else {
        /* if the entered size does not match acceptable size */
        printf("Invalid AES key size\n");
        ret = -1080;
    }

    return ret;
}

from wolfssl-examples.

kenyiesnc avatar kenyiesnc commented on May 24, 2024

Ok thanks for confirming. I was using the example code as basis for code in my program.

from wolfssl-examples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.