(root)/
libxcrypt-4.4.36/
lib/
alg-gost3411-2012-hmac.h
       1  /* Copyright (C) 2018 vt@altlinux.org
       2   * Copyright (C) 2018 Björn Esser <besser82@fedoraproject.org>
       3   *
       4   * Redistribution and use in source and binary forms, with or without
       5   * modification, are permitted.
       6   *
       7   * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
       8   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
       9   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
      10   * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
      11   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
      12   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
      13   * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
      14   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
      15   * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
      16   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
      17   * SUCH DAMAGE.
      18   */
      19  
      20  #ifndef _CRYPT_ALG_GOST3411_2012_HMAC_H
      21  #define _CRYPT_ALG_GOST3411_2012_HMAC_H
      22  
      23  #include "alg-gost3411-2012-core.h"
      24  
      25  /* Constants for HMAC_GOSTR3411_2012_256 */
      26  #define GOSTR3411_2012_L 32 /* hash output len */
      27  #define GOSTR3411_2012_B 64 /* hash input len (512) */
      28  #define GOSTR3411_2012_BITS GOSTR3411_2012_L * 8 /* 256 */
      29  
      30  typedef struct
      31  {
      32    GOST34112012Context ctx;
      33    unsigned char pad[GOSTR3411_2012_B];   /* ipad and opad */
      34    unsigned char kstar[GOSTR3411_2012_B]; /* derived key */
      35    unsigned char digest[GOSTR3411_2012_L];
      36  } gost_hmac_256_t;
      37  
      38  extern void
      39  gost_hash256 (const uint8_t *t, size_t n, uint8_t *out32,
      40                GOST34112012Context *ctx);
      41  
      42  extern void
      43  gost_hmac256 (const uint8_t *k, size_t n, const uint8_t *t, size_t len,
      44                uint8_t *out32, gost_hmac_256_t *gostbuf);
      45  
      46  #endif /* alg-gost3411-2012-hmac.h */