Jean-Baptiste Kempf pushed to branch master at VideoLAN / libaacs
Commits:
c67d1c7b by Fabrice Bellet at 2019-07-28T08:22:52Z
crypto: fix libgcrypt mpi to binary padding
- - - - -
1 changed file:
- src/libaacs/crypto.c
Changes:
=====================================
src/libaacs/crypto.c
=====================================
@@ -517,8 +517,17 @@ void crypto_aacs_sign(const uint8_t *cert, const uint8_t
*priv_key, uint8_t *sig
/* Finally concatenate 'r' and 's' to get the ECDSA signature */
mpi_r = gcry_sexp_nth_mpi (sexp_r, 1, GCRYMPI_FMT_USG);
mpi_s = gcry_sexp_nth_mpi (sexp_s, 1, GCRYMPI_FMT_USG);
- gcry_mpi_print (GCRYMPI_FMT_USG, signature, 20, NULL, mpi_r);
- gcry_mpi_print (GCRYMPI_FMT_USG, signature + 20, 20, NULL, mpi_s);
+ size_t n;
+ gcry_mpi_print (GCRYMPI_FMT_USG, signature, 20, &n, mpi_r);
+ if (n < 20) {
+ memmove (signature + 20 - n, signature, n);
+ memset (signature, 0, 20 - n);
+ }
+ gcry_mpi_print (GCRYMPI_FMT_USG, signature + 20, 20, &n, mpi_s);
+ if (n < 20) {
+ memmove (signature + 40 - n, signature + 20, n);
+ memset (signature + 20, 0, 20 - n);
+ }
error:
@@ -766,8 +775,17 @@ void crypto_create_host_key_pair(uint8_t *host_key,
uint8_t *host_key_point)
gcry_mpi_t q_y = mpi_new(0);
_gcry_mpi_ec_get_affine (q_x, q_y, &Q, ctx);
- gcry_mpi_print (GCRYMPI_FMT_USG, host_key_point, 20, NULL, q_x);
- gcry_mpi_print (GCRYMPI_FMT_USG, host_key_point + 20, 20, NULL, q_y);
+ size_t n;
+ gcry_mpi_print (GCRYMPI_FMT_USG, host_key_point, 20, &n, q_x);
+ if (n < 20) {
+ memmove (host_key_point + 20 - n, host_key_point, n);
+ memset (host_key_point, 0, 20 - n);
+ }
+ gcry_mpi_print (GCRYMPI_FMT_USG, host_key_point + 20, 20, &n, q_y);
+ if (n < 20) {
+ memmove (host_key_point + 40 - n, host_key_point + 20, n);
+ memset (host_key_point + 20, 0, 20 - n);
+ }
/* cleanup */
View it on GitLab:
https://code.videolan.org/videolan/libaacs/commit/c67d1c7b0aa9e9ad9921c63ffcd3bc5f603980a6
--
View it on GitLab:
https://code.videolan.org/videolan/libaacs/commit/c67d1c7b0aa9e9ad9921c63ffcd3bc5f603980a6
You're receiving this email because of your account on code.videolan.org.
_______________________________________________
libaacs-devel mailing list
[email protected]
https://mailman.videolan.org/listinfo/libaacs-devel