LCOV - code coverage report
Current view: top level - src/common - sha2_openssl.c (source / functions) Hit Total Coverage
Test: PostgreSQL 13beta1 Lines: 36 36 100.0 %
Date: 2020-06-03 09:06:53 Functions: 12 12 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*-------------------------------------------------------------------------
       2             :  *
       3             :  * sha2_openssl.c
       4             :  *    Set of wrapper routines on top of OpenSSL to support SHA-224
       5             :  *    SHA-256, SHA-384 and SHA-512 functions.
       6             :  *
       7             :  * This should only be used if code is compiled with OpenSSL support.
       8             :  *
       9             :  * Portions Copyright (c) 2016-2020, PostgreSQL Global Development Group
      10             :  *
      11             :  * IDENTIFICATION
      12             :  *        src/common/sha2_openssl.c
      13             :  *
      14             :  *-------------------------------------------------------------------------
      15             :  */
      16             : 
      17             : #ifndef FRONTEND
      18             : #include "postgres.h"
      19             : #else
      20             : #include "postgres_fe.h"
      21             : #endif
      22             : 
      23             : #include <openssl/sha.h>
      24             : 
      25             : #include "common/sha2.h"
      26             : 
      27             : 
      28             : /* Interface routines for SHA-256 */
      29             : void
      30      807482 : pg_sha256_init(pg_sha256_ctx *ctx)
      31             : {
      32      807482 :     SHA256_Init((SHA256_CTX *) ctx);
      33      807482 : }
      34             : 
      35             : void
      36     1717832 : pg_sha256_update(pg_sha256_ctx *ctx, const uint8 *data, size_t len)
      37             : {
      38     1717832 :     SHA256_Update((SHA256_CTX *) ctx, data, len);
      39     1717832 : }
      40             : 
      41             : void
      42      807474 : pg_sha256_final(pg_sha256_ctx *ctx, uint8 *dest)
      43             : {
      44      807474 :     SHA256_Final(dest, (SHA256_CTX *) ctx);
      45      807474 : }
      46             : 
      47             : /* Interface routines for SHA-512 */
      48             : void
      49        3742 : pg_sha512_init(pg_sha512_ctx *ctx)
      50             : {
      51        3742 :     SHA512_Init((SHA512_CTX *) ctx);
      52        3742 : }
      53             : 
      54             : void
      55       13794 : pg_sha512_update(pg_sha512_ctx *ctx, const uint8 *data, size_t len)
      56             : {
      57       13794 :     SHA512_Update((SHA512_CTX *) ctx, data, len);
      58       13794 : }
      59             : 
      60             : void
      61        3742 : pg_sha512_final(pg_sha512_ctx *ctx, uint8 *dest)
      62             : {
      63        3742 :     SHA512_Final(dest, (SHA512_CTX *) ctx);
      64        3742 : }
      65             : 
      66             : /* Interface routines for SHA-384 */
      67             : void
      68        3742 : pg_sha384_init(pg_sha384_ctx *ctx)
      69             : {
      70        3742 :     SHA384_Init((SHA512_CTX *) ctx);
      71        3742 : }
      72             : 
      73             : void
      74       13794 : pg_sha384_update(pg_sha384_ctx *ctx, const uint8 *data, size_t len)
      75             : {
      76       13794 :     SHA384_Update((SHA512_CTX *) ctx, data, len);
      77       13794 : }
      78             : 
      79             : void
      80        3742 : pg_sha384_final(pg_sha384_ctx *ctx, uint8 *dest)
      81             : {
      82        3742 :     SHA384_Final(dest, (SHA512_CTX *) ctx);
      83        3742 : }
      84             : 
      85             : /* Interface routines for SHA-224 */
      86             : void
      87        3742 : pg_sha224_init(pg_sha224_ctx *ctx)
      88             : {
      89        3742 :     SHA224_Init((SHA256_CTX *) ctx);
      90        3742 : }
      91             : 
      92             : void
      93       13794 : pg_sha224_update(pg_sha224_ctx *ctx, const uint8 *data, size_t len)
      94             : {
      95       13794 :     SHA224_Update((SHA256_CTX *) ctx, data, len);
      96       13794 : }
      97             : 
      98             : void
      99        3742 : pg_sha224_final(pg_sha224_ctx *ctx, uint8 *dest)
     100             : {
     101        3742 :     SHA224_Final(dest, (SHA256_CTX *) ctx);
     102        3742 : }

Generated by: LCOV version 1.13