src/wolfSSL/src/internal.c
static int Poly1305TagOld(WOLFSSL* ssl, byte* additional, const byte* out,
                       byte* cipher, word16 sz, byte* tag)
{
    int ret       = 0;
    int msglen    = (sz - ssl->specs.aead_mac_size);
    word32 keySz  = 32;
    byte padding[8]; /* used to temporarily store lengths */

#ifdef CHACHA_AEAD_TEST
      printf("Using old version of poly1305 input.\n");
#endif

    if (msglen < 0)
        return INPUT_CASE_ERROR;

    if ((ret = wc_Poly1305SetKey(ssl->auth.poly1305, cipher, keySz)) != 0)
        return ret;

    if ((ret = wc_Poly1305Update(ssl->auth.poly1305, additional,
                   AEAD_AUTH_DATA_SZ)) != 0)
        return ret;

    /* length of additional input plus padding */
    XMEMSET(padding, 0, sizeof(padding));
    padding[0] = AEAD_AUTH_DATA_SZ;
    if ((ret = wc_Poly1305Update(ssl->auth.poly1305, padding,
                    sizeof(padding))) != 0)
        return ret;


    /* add cipher info and then its length */
    XMEMSET(padding, 0, sizeof(padding));
    if ((ret = wc_Poly1305Update(ssl->auth.poly1305, out, msglen)) != 0)
        return ret;

    /* 32 bit size of cipher to 64 bit endian */
    padding[0] =  msglen        & 0xff;
    padding[1] = (msglen >>  8) & 0xff;
    padding[2] = (msglen >> 16) & 0xff;
    padding[3] = (msglen >> 24) & 0xff;
    if ((ret = wc_Poly1305Update(ssl->auth.poly1305, padding, sizeof(padding)))
        != 0)
        return ret;

    /* generate tag */
    if ((ret = wc_Poly1305Final(ssl->auth.poly1305, tag)) != 0)
        return ret;

    return ret;
}
/* Used for the older version of creating AEAD tags with Poly1305 */
Used for the older version of creating AEAD tags with Poly1305
Used for the older version of creating AEAD tags with Poly1305
static int Poly1305TagOld(WOLFSSL* ssl, byte* additional, const byte* out,
                       byte* cipher, word16 sz, byte* tag)
{
    int ret       = 0;
    int msglen    = (sz - ssl->specs.aead_mac_size);
    word32 keySz  = 32;
    byte padding[8]; 
#ifdef CHACHA_AEAD_TEST
      printf("Using old version of poly1305 input.\n");
#endif
    if (msglen < 0)
        return INPUT_CASE_ERROR;
    if ((ret = wc_Poly1305SetKey(ssl->auth.poly1305, cipher, keySz)) != 0)
        return ret;
    if ((ret = wc_Poly1305Update(ssl->auth.poly1305, additional,
                   AEAD_AUTH_DATA_SZ)) != 0)
        return ret;
    XMEMSET(padding, 0, sizeof(padding));
    padding[0] = AEAD_AUTH_DATA_SZ;
    if ((ret = wc_Poly1305Update(ssl->auth.poly1305, padding,
                    sizeof(padding))) != 0)
        return ret;
    XMEMSET(padding, 0, sizeof(padding));
    if ((ret = wc_Poly1305Update(ssl->auth.poly1305, out, msglen)) != 0)
        return ret;
    padding[0] =  msglen        & 0xff;
    padding[1] = (msglen >>  8) & 0xff;
    padding[2] = (msglen >> 16) & 0xff;
    padding[3] = (msglen >> 24) & 0xff;
    if ((ret = wc_Poly1305Update(ssl->auth.poly1305, padding, sizeof(padding)))
        != 0)
        return ret;
    if ((ret = wc_Poly1305Final(ssl->auth.poly1305, tag)) != 0)
        return ret;
    return ret;
}
static int Poly1305TagOld ( WOLFSSL * ssl , byte * additional , const byte * out , byte * cipher , word16 sz , byte * tag ) { int ret = 0 ; int msglen = ( sz - ssl -> specs . aead_mac_size ) ; word32 keySz = 32 ; byte padding [ 8 ] ; #ifdef CHACHA_AEAD_TEST printf ( " \n " ) ; #endif if ( msglen < 0 ) return INPUT_CASE_ERROR ; if ( ( ret = wc_Poly1305SetKey ( ssl -> auth . poly1305 , cipher , keySz ) ) != 0 ) return ret ; if ( ( ret = wc_Poly1305Update ( ssl -> auth . poly1305 , additional , AEAD_AUTH_DATA_SZ ) ) != 0 ) return ret ; XMEMSET ( padding , 0 , sizeof ( padding ) ) ; padding [ 0 ] = AEAD_AUTH_DATA_SZ ; if ( ( ret = wc_Poly1305Update ( ssl -> auth . poly1305 , padding , sizeof ( padding ) ) ) != 0 ) return ret ; XMEMSET ( padding , 0 , sizeof ( padding ) ) ; if ( ( ret = wc_Poly1305Update ( ssl -> auth . poly1305 , out , msglen ) ) != 0 ) return ret ; padding [ 0 ] = msglen & 0xff ; padding [ 1 ] = ( msglen >> 8 ) & 0xff ; padding [ 2 ] = ( msglen >> 16 ) & 0xff ; padding [ 3 ] = ( msglen >> 24 ) & 0xff ; if ( ( ret = wc_Poly1305Update ( ssl -> auth . poly1305 , padding , sizeof ( padding ) ) ) != 0 ) return ret ; if ( ( ret = wc_Poly1305Final ( ssl -> auth . poly1305 , tag ) ) != 0 ) return ret ; return ret ; }
Used for the older version of creating AEAD tags with Poly1305
Used for the older version of creating AEAD tags with Poly1305
/* used to temporarily store lengths */ /* length of additional input plus padding */ /* add cipher info and then its length */ /* 32 bit size of cipher to 64 bit endian */ /* generate tag */