Skip to content

Build fails with Intel OneAPI 2021.3.0 (unsafe conversions) #166

Open

Description

@DavidHuber-NOAA

When attempting to build with Intel 2021.3.0, the following error messages appear at lib/alg-gost3411-2012-hmac.c lines 48, 53, and 63:

error #2259: non-pointer conversion from "int" to "unsigned char" may lose significant bits.

Activity

  1. self-assigned this
    on Jan 23, 2023
  2. added
    bugConfirmed to be a bug in libxcrypt.
    on Jan 23, 2023
  3. besser82 commented on Jan 23, 2023

    @besser82
    Owner

    Thank you for the bug report!

    Does the following patch fix your issue?

    diff --git a/lib/alg-gost3411-2012-hmac.c b/lib/alg-gost3411-2012-hmac.c
    index 45001d2..6549a48 100644
    --- a/lib/alg-gost3411-2012-hmac.c
    +++ b/lib/alg-gost3411-2012-hmac.c
    @@ -45,12 +45,12 @@ gost_hmac256 (const uint8_t *k, size_t n, const uint8_t *t, size_t len,
       assert (n >= GOSTR3411_2012_L && n <= GOSTR3411_2012_B);
     
       for (i = 0; i < sizeof (gostbuf->pad); i++)
    -    gostbuf->kstar[i] = i < n ? k[i] : 0;
    +    gostbuf->kstar[i] = (unsigned char)(i < n ? k[i] : 0);
     
       GOST34112012Init (&gostbuf->ctx, GOSTR3411_2012_BITS);
     
       for (i = 0; i < sizeof (gostbuf->pad); i++)
    -    gostbuf->pad[i] = gostbuf->kstar[i] ^ 0x36; /* ipad */
    +    gostbuf->pad[i] = (unsigned char)(gostbuf->kstar[i] ^ 0x36); /* ipad */
     
       GOST34112012Update (&gostbuf->ctx, gostbuf->pad,
                           sizeof (gostbuf->pad));
    @@ -60,7 +60,7 @@ gost_hmac256 (const uint8_t *k, size_t n, const uint8_t *t, size_t len,
       GOST34112012Init (&gostbuf->ctx, GOSTR3411_2012_BITS);
     
       for (i = 0; i < sizeof (gostbuf->pad); i++)
    -    gostbuf->pad[i] = gostbuf->kstar[i] ^ 0x5c; /* opad */
    +    gostbuf->pad[i] = (unsigned char)(gostbuf->kstar[i] ^ 0x5c); /* opad */
     
       GOST34112012Update (&gostbuf->ctx, gostbuf->pad,
                           sizeof (gostbuf->pad));
    
  4. DavidHuber-NOAA commented on Jan 23, 2023

    @DavidHuber-NOAA
    Author

    @besser82 That did get a bit further. Now I am getting a similar error at lib/alg-md4.c, line 203: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem).

  5. besser82 commented on Jan 23, 2023

    @besser82
    Owner

    @DavidHuber-NOAA, please try this:

    diff --git a/lib/alg-md4.c b/lib/alg-md4.c
    index 0b399fa..410c947 100644
    --- a/lib/alg-md4.c
    +++ b/lib/alg-md4.c
    @@ -200,7 +200,7 @@ void MD4_Update(MD4_CTX *ctx, const void *data, size_t size)
     	unsigned long used, available;
     
     	saved_lo = ctx->lo;
    -	if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
    +	if ((ctx->lo = (MD4_u32plus)((saved_lo + size) & 0x1fffffff)) < saved_lo)
     		ctx->hi++;
     	ctx->hi += (MD4_u32plus) size >> 29;
     
    

    Be aware that the line in this patch are using tabs for indentation.

  6. DavidHuber-NOAA commented on Jan 23, 2023

    @DavidHuber-NOAA
    Author

    I ran into a few more similar issues and pushed to a branch. However, I ran into one I'm not really sure how to fix. Lines 158-164, 1110, 1322, 1335, and 1336 of lib/alg-yescrypt-opt.c produce the following: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem).

  7. besser82 commented on Jan 23, 2023

    @besser82
    Owner

    Cool, would you mind sharing your efforts? I will look into the yescrypt stuff during tomorrow.

  8. DavidHuber-NOAA commented on Jan 23, 2023

    @DavidHuber-NOAA
    Author

    Yeah, I linked it to this issue. It can be found here.

  9. added
    help wantedThe libxcrypt core developers do not plan to work on this themselves but would review a PR.
    on Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugConfirmed to be a bug in libxcrypt.help wantedThe libxcrypt core developers do not plan to work on this themselves but would review a PR.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions