1. 09 Dec, 2022 12 commits
  2. 05 Dec, 2022 1 commit
  3. 02 Dec, 2022 25 commits
  4. 25 Nov, 2022 2 commits
    • Jason A. Donenfeld's avatar
      hwrng: u2fzero - account for high quality RNG · 83478938
      Jason A. Donenfeld authored
      The U2F zero apparently has a real TRNG in it with maximum quality, not
      one with quality of "1", which was likely a misinterpretation of the
      field as a boolean. So remove the assignment entirely, so that we get
      the default quality setting.
      
      In the u2f-zero firmware, the 0x21 RNG command used by this driver is
      handled as such [1]:
      
        case U2F_CUSTOM_GET_RNG:
          if (atecc_send_recv(ATECC_CMD_RNG,ATECC_RNG_P1,ATECC_RNG_P2,
            NULL, 0,
            appdata.tmp,
            sizeof(appdata.tmp), &res) == 0 )
          {
            memmove(msg->pkt.init.payload, res.buf, 32);
            U2FHID_SET_LEN(msg, 32);
            usb_write((uint8_t*)msg, 64);
          }
          else
          {
            U2FHID_SET_LEN(msg, 0);
            usb_write((uint8_t*)msg, 64);
          }
      
      This same call to `atecc_send_recv(ATECC_CMD_RNG,ATECC_RNG_P1,
      ATECC_RNG_P2,...)` is then also used in the token's cryptographically
      critical "u2f_new_keypair" function, as its rather straightforward
      source of random bytes [2]:
      
        int8_t u2f_new_keypair(uint8_t * handle, uint8_t * appid, uint8_t * pubkey)
        {
          struct atecc_response res;
          uint8_t private_key[36];
          int i;
      
          watchdog();
      
          if (atecc_send_recv(ATECC_CMD_RNG,ATECC_RNG_P1,ATECC_RNG_P2,
            NULL, 0,
            appdata.tmp,
            sizeof(appdata.tmp), &res) != 0 )
          {
            return -1;
          }
      
      So it seems rather plain that the ATECC RNG is considered to provide
      good random numbers.
      
      [1] https://github.com/conorpp/u2f-zero/blob/master/firmware/src/custom.c
      [2] https://github.com/conorpp/u2f-zero/blob/master/firmware/src/u2f_atecc.c
      
      Cc: Andrej Shadura <andrew.shadura@collabora.co.uk>
      Cc: Jiri Kosina <jkosina@suse.cz>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      Acked-by: default avatarAndrej Shadura <andrew.shadura@collabora.co.uk>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      83478938
    • Weili Qian's avatar
      crypto: hisilicon/qm - add device status check when start fails · 5f9c97a0
      Weili Qian authored
      In function 'hisi_qm_resume', if the device fails to be started,
      directly returning error code will cause the device to be unavailable.
      However, the failure may be caused by device error, which will be
      reported to the driver, and driver can reset and restart device.
      Therefore, check device status instead of returning error code
      directly. Returns 0 if device error has occurred, otherwise returns
      error code.
      Signed-off-by: default avatarWeili Qian <qianweili@huawei.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      5f9c97a0