unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
blob 6c9b70a58777706a61cfae68710c81f945e072a9 3828 bytes (raw)
name: lib/gl_openssl.h 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
 
/* Wrap openssl crypto hash routines in gnulib interface.  -*- coding: utf-8 -*-

   Copyright (C) 2013-2021 Free Software Foundation, Inc.

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */

/* Written by Pádraig Brady */

#ifndef GL_OPENSSL_NAME
# error "Please define GL_OPENSSL_NAME to 1,5,256 etc."
#endif

#ifndef _GL_INLINE_HEADER_BEGIN
# error "Please include config.h first."
#endif
_GL_INLINE_HEADER_BEGIN
#ifndef GL_OPENSSL_INLINE
# define GL_OPENSSL_INLINE _GL_INLINE
#endif

/* Concatenate two preprocessor tokens.  */
#define _GLCRYPTO_CONCAT_(prefix, suffix) prefix##suffix
#define _GLCRYPTO_CONCAT(prefix, suffix) _GLCRYPTO_CONCAT_ (prefix, suffix)

#if GL_OPENSSL_NAME == 5
# define OPENSSL_ALG md5
#else
# define OPENSSL_ALG _GLCRYPTO_CONCAT (sha, GL_OPENSSL_NAME)
#endif

/* Context type mappings.  */
#if BASE_OPENSSL_TYPE != GL_OPENSSL_NAME
# undef BASE_OPENSSL_TYPE
# if GL_OPENSSL_NAME == 224
#  define BASE_OPENSSL_TYPE 256
# elif GL_OPENSSL_NAME == 384
#  define BASE_OPENSSL_TYPE 512
# endif
# define md5_CTX MD5_CTX
# define sha1_CTX SHA_CTX
# define sha224_CTX SHA256_CTX
# define sha224_ctx sha256_ctx
# define sha256_CTX SHA256_CTX
# define sha384_CTX SHA512_CTX
# define sha384_ctx sha512_ctx
# define sha512_CTX SHA512_CTX
# undef _gl_CTX
# undef _gl_ctx
# define _gl_CTX _GLCRYPTO_CONCAT (OPENSSL_ALG, _CTX) /* openssl type.  */
# define _gl_ctx _GLCRYPTO_CONCAT (OPENSSL_ALG, _ctx) /* gnulib type.  */

struct _gl_ctx { _gl_CTX CTX; };
#endif

/* Function name mappings.  */
#define md5_prefix MD5
#define sha1_prefix SHA1
#define sha224_prefix SHA224
#define sha256_prefix SHA256
#define sha384_prefix SHA384
#define sha512_prefix SHA512
#define _GLCRYPTO_PREFIX _GLCRYPTO_CONCAT (OPENSSL_ALG, _prefix)
#define OPENSSL_FN(suffix) _GLCRYPTO_CONCAT (_GLCRYPTO_PREFIX, suffix)
#define GL_CRYPTO_FN(suffix) _GLCRYPTO_CONCAT (OPENSSL_ALG, suffix)

GL_OPENSSL_INLINE void
GL_CRYPTO_FN (_init_ctx) (struct _gl_ctx *ctx)
{ (void) OPENSSL_FN (_Init) ((_gl_CTX *) ctx); }

/* These were never exposed by gnulib.  */
#if ! (GL_OPENSSL_NAME == 224 || GL_OPENSSL_NAME == 384)
GL_OPENSSL_INLINE void
GL_CRYPTO_FN (_process_bytes) (const void *buf, size_t len, struct _gl_ctx *ctx)
{ OPENSSL_FN (_Update) ((_gl_CTX *) ctx, buf, len); }

GL_OPENSSL_INLINE void
GL_CRYPTO_FN (_process_block) (const void *buf, size_t len, struct _gl_ctx *ctx)
{ GL_CRYPTO_FN (_process_bytes) (buf, len, ctx); }
#endif

GL_OPENSSL_INLINE void *
GL_CRYPTO_FN (_finish_ctx) (struct _gl_ctx *ctx, void *restrict res)
{ OPENSSL_FN (_Final) ((unsigned char *) res, (_gl_CTX *) ctx); return res; }

GL_OPENSSL_INLINE void *
GL_CRYPTO_FN (_buffer) (const char *buf, size_t len, void *restrict res)
{ return OPENSSL_FN () ((const unsigned char *) buf, len, (unsigned char *) res); }

GL_OPENSSL_INLINE void *
GL_CRYPTO_FN (_read_ctx) (const struct _gl_ctx *ctx, void *restrict res)
{
  /* Assume any unprocessed bytes in ctx are not to be ignored.  */
  _gl_CTX tmp_ctx = *(_gl_CTX *) ctx;
  OPENSSL_FN (_Final) ((unsigned char *) res, &tmp_ctx);
  return res;
}

/* Undef so we can include multiple times.  */
#undef GL_CRYPTO_FN
#undef OPENSSL_FN
#undef _GLCRYPTO_PREFIX
#undef OPENSSL_ALG
#undef GL_OPENSSL_NAME

_GL_INLINE_HEADER_END

debug log:

solving 6c9b70a587777 ...
found 6c9b70a587777 in https://yhetil.org/emacs-bugs/CAOqdjBe=-aWeu8Cs1MV7xjKr9FHC6Jy7B4fALXUQ0+KnaVNiUQ@mail.gmail.com/

applying [1/1] https://yhetil.org/emacs-bugs/CAOqdjBe=-aWeu8Cs1MV7xjKr9FHC6Jy7B4fALXUQ0+KnaVNiUQ@mail.gmail.com/
diff --git a/lib/gl_openssl.h b/lib/gl_openssl.h
new file mode 100644
index 0000000000000..6c9b70a587777

Checking patch lib/gl_openssl.h...
Applied patch lib/gl_openssl.h cleanly.

index at:
100644 6c9b70a58777706a61cfae68710c81f945e072a9	lib/gl_openssl.h

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).