]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Use polyvalx in cgo.
authorNick Mathewson <nickm@torproject.org>
Thu, 15 May 2025 14:59:01 +0000 (10:59 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 21 May 2025 17:00:03 +0000 (13:00 -0400)
src/core/crypto/relay_crypto_cgo.c
src/core/crypto/relay_crypto_cgo.h

index 079b867fbd1db48efcbbe0cc958f9de488ad00ee..c833e6a87b2742cb0b2aba5c4c82e1bcc25c384d 100644 (file)
@@ -54,7 +54,7 @@ cgo_et_init(cgo_et_t *et, int aesbits, bool encrypt,
   et->kb = aes_raw_new(key, aesbits, encrypt);
   if (et->kb == NULL)
     return -1;
-  polyval_key_init(&et->ku, key + aes_key_bytes);
+  polyvalx_init(&et->ku, key + aes_key_bytes);
   return 0;
 }
 /** Replace the key on an existing, already initialized cgo_et_t.
@@ -66,25 +66,24 @@ cgo_et_set_key(cgo_et_t *et, int aesbits, bool encrypt,
 {
   size_t aes_key_bytes = aesbits / 8;
   aes_raw_set_key(&et->kb, key, aesbits, encrypt);
-  polyval_key_init(&et->ku, key + aes_key_bytes);
+  polyvalx_init(&et->ku, key + aes_key_bytes);
 }
 
 /** Helper: Compute polyval(KU, H | CMD | X_R). */
 static inline void
-compute_et_mask(polyval_key_t *pvk, const et_tweak_t tweak, uint8_t *t_out)
+compute_et_mask(polyvalx_t *pvk, const et_tweak_t tweak, uint8_t *t_out)
 {
   // block 0: tweak.h
   // block 1: one byte of command, first 15 bytes of x_r
   // block 2...: remainder of x_r, zero-padded.
-  polyval_t pv;
+  polyvalx_reset(pvk);
   uint8_t block1[16];
   block1[0] = tweak.uiv.cmd;
   memcpy(block1+1, tweak.x_r, 15);
-  polyval_init_from_key(&pv, pvk);
-  polyval_add_block(&pv, tweak.uiv.h);
-  polyval_add_block(&pv, block1);
-  polyval_add_zpad(&pv, tweak.x_r + 15, ET_TWEAK_LEN_X_R - 15);
-  polyval_get_tag(&pv, t_out);
+  polyvalx_add_block(pvk, tweak.uiv.h);
+  polyvalx_add_block(pvk, block1);
+  polyvalx_add_zpad(pvk, tweak.x_r + 15, ET_TWEAK_LEN_X_R - 15);
+  polyvalx_get_tag(pvk, t_out);
 }
 /** XOR the 16 byte block from inp into out. */
 static void
index 208d7ef2bc0609e1fd89e22efc31144f29a202c0..83a8274ef529e48240a5f9bdcecbe253210a273e 100644 (file)
@@ -77,9 +77,9 @@ typedef struct cgo_et_t {
    */
   aes_raw_t *kb;
   /**
-   * Polyval key.
+   * Polyval instance, with expanded key.
    */
-  polyval_key_t ku;
+  polyvalx_t ku;
 } cgo_et_t;
 /**
  * Keyed pseudorandom function, based on polyval and AES-CTR.