Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Jul 12, 2024
  2. Jun 27, 2024
  3. Jun 16, 2024
  4. Jun 07, 2024
  5. May 31, 2024
  6. May 17, 2024
  7. May 13, 2024
  8. May 10, 2024
  9. Apr 26, 2024
    • Stefan Berger's avatar
      crypto: ecdh - Initialize ctx->private_key in proper byte order · 01474b70
      Stefan Berger authored
      
      The private key in ctx->private_key is currently initialized in reverse
      byte order in ecdh_set_secret and whenever the key is needed in proper
      byte order the variable priv is introduced and the bytes from
      ctx->private_key are copied into priv while being byte-swapped
      (ecc_swap_digits). To get rid of the unnecessary byte swapping initialize
      ctx->private_key in proper byte order and clean up all functions that were
      previously using priv or were called with ctx->private_key:
      
      - ecc_gen_privkey: Directly initialize the passed ctx->private_key with
        random bytes filling all the digits of the private key. Get rid of the
        priv variable. This function only has ecdh_set_secret as a caller to
        create NIST P192/256/384 private keys.
      
      - crypto_ecdh_shared_secret: Called only from ecdh_compute_value with
        ctx->private_key. Get rid of the priv variable and work with the passed
        private_key directly.
      
      - ecc_make_pub_key: Called only from ecdh_compute_value with
        ctx->private_key. Get rid of the priv variable and work with the passed
        private_key directly.
      
      Cc: Salvatore Benedetto <salvatore.benedetto@intel.com>
      Signed-off-by: default avatarStefan Berger <stefanb@linux.ibm.com>
      Acked-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      01474b70
    • Stefan Berger's avatar
      crypto: ecdh - Pass private key in proper byte order to check valid key · bd955a4e
      Stefan Berger authored
      
      ecc_is_key_valid expects a key with the most significant digit in the last
      entry of the digit array. Currently ecdh_set_secret passes a reversed key
      to ecc_is_key_valid that then passes the rather simple test checking
      whether the private key is in range [2, n-3]. For all current ecdh-
      supported curves (NIST P192/256/384) the 'n' parameter is a rather large
      number, therefore easily passing this test.
      
      Throughout the ecdh and ecc codebase the variable 'priv' is used for a
      private_key holding the bytes in proper byte order. Therefore, introduce
      priv in ecdh_set_secret and copy the bytes from ctx->private_key into
      priv in proper byte order by using ecc_swap_digits. Pass priv to
      ecc_is_valid_key.
      
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: Salvatore Benedetto <salvatore.benedetto@intel.com>
      Signed-off-by: default avatarStefan Berger <stefanb@linux.ibm.com>
      Acked-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      bd955a4e
    • Hailey Mothershead's avatar
      crypto: aead,cipher - zeroize key buffer after use · 23e4099b
      Hailey Mothershead authored
      
      I.G 9.7.B for FIPS 140-3 specifies that variables temporarily holding
      cryptographic information should be zeroized once they are no longer
      needed. Accomplish this by using kfree_sensitive for buffers that
      previously held the private key.
      
      Signed-off-by: default avatarHailey Mothershead <hailmo@amazon.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      23e4099b
  10. Apr 24, 2024
  11. Apr 12, 2024
  12. Apr 05, 2024