Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make caller enforce invariants when setting AES encryption key #702

Merged
merged 1 commit into from
Oct 24, 2018

Commits on Oct 24, 2018

  1. Make caller enforce invariants when setting AES encryption key

    `GFp_AES_set_encrypt_key` can fail if and only if the following invariants
    are violated.
    
    * All pointer arguments must be non-null.
    * The key size must be either 128 or 256 bits (192 bit keys aren't
    supported).
    
    The first invariant should not be checked at runtime (except via
    assertion) as it is the responsibility of the caller.
    
    The second could be expressed statically by accepting an enum with the
    valid key lengths, but enums don't provide any type safety in C.
    Instead, we document the acceptable key lengths and make them the
    responsibility of the caller.
    
    As a result of these changes, `GFp_AES_set_encrypt_key` (as well as
    `GFp_aes_c_set_encrypt_key`) no longer needs to return an error code.
    The assembly functions still return an error code and do input
    validation.
    
    This commit also corrects the signature of `GFp_AES_set_encrypt_key`.
    
    I agree to license my contributions to each file under the terms given
    at the top of each file I changed.
    ecstatic-morse committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    38d54b9 View commit details
    Browse the repository at this point in the history