OpenVPN
crypto.h
Go to the documentation of this file.
1 /*
2  * OpenVPN -- An application to securely tunnel IP networks
3  * over a single TCP/UDP port, with support for SSL/TLS-based
4  * session authentication and key exchange,
5  * packet encryption, packet authentication, and
6  * packet compression.
7  *
8  * Copyright (C) 2002-2024 OpenVPN Inc <sales@openvpn.net>
9  * Copyright (C) 2010-2021 Fox Crypto B.V. <openvpn@foxcrypto.com>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2
13  * as published by the Free Software Foundation.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24 
123 #ifndef CRYPTO_H
124 #define CRYPTO_H
125 
126 #include "crypto_backend.h"
127 #include "basic.h"
128 #include "buffer.h"
129 #include "packet_id.h"
130 #include "mtu.h"
131 
135 };
136 
137 /*
138  * Defines a key type and key length for both cipher and HMAC.
139  */
140 struct key_type
141 {
142  const char *cipher;
143  const char *digest;
144 };
145 
151 struct key
152 {
157 };
158 
165 
168 
171 
174 
178  uint16_t epoch;
179 };
180 
188 void
189 key_parameters_from_key(struct key_parameters *key_params, const struct key *key);
190 
191 struct epoch_key {
193  uint16_t epoch;
194 };
195 
200 struct key_ctx
201 {
227  uint16_t epoch;
228 };
229 
230 #define KEY_DIRECTION_BIDIRECTIONAL 0 /* same keys for both directions */
231 #define KEY_DIRECTION_NORMAL 1 /* encrypt with keys[0], decrypt with keys[1] */
232 #define KEY_DIRECTION_INVERSE 2 /* encrypt with keys[1], decrypt with keys[0] */
233 
238 struct key2
239 {
240  int n;
242  struct key keys[2];
246 };
247 
258 {
259  int out_key;
261  int in_key;
263  int need_keys;
271 };
272 
279 {
280  struct key_ctx encrypt;
282  struct key_ctx decrypt;
285 };
286 
292 {
302 
305 
308 
313 
322 
325 
329 
344 #define CO_PACKET_ID_LONG_FORM (1<<0)
345 
347 #define CO_IGNORE_PACKET_ID (1<<1)
348 
353 #define CO_MUTE_REPLAY_WARNINGS (1<<2)
354 
356 #define CO_USE_TLS_KEY_MATERIAL_EXPORT (1<<3)
357 
360 #define CO_RESEND_WKC (1<<4)
361 
364 #define CO_FORCE_TLSCRYPTV2_COOKIE (1<<5)
365 
368 #define CO_USE_CC_EXIT_NOTIFY (1<<6)
369 
372 #define CO_USE_DYNAMIC_TLS_CRYPT (1<<7)
373 
376 #define CO_EPOCH_DATA_KEY_FORMAT (1<<8)
377 
383  unsigned int flags;
385 };
386 
387 #define CRYPT_ERROR_EXIT(flags, format) \
388  do { msg(flags, "%s: " format, error_prefix); goto error_exit; } while (false)
389 
390 #define CRYPT_ERROR(format) CRYPT_ERROR_EXIT(D_CRYPT_ERRORS, format)
391 #define CRYPT_DROP(format) CRYPT_ERROR_EXIT(D_MULTI_DROPPED, format)
392 
397 #define OPENVPN_AEAD_MIN_IV_LEN (sizeof(packet_id_type) + 8)
398 
399 #define RKF_MUST_SUCCEED (1<<0)
400 #define RKF_INLINE (1<<1)
401 void read_key_file(struct key2 *key2, const char *file, const unsigned int flags);
402 
408 int write_key_file(const int nkeys, const char *filename);
409 
410 bool check_key(struct key *key, const struct key_type *kt);
411 
422 void init_key_type(struct key_type *kt, const char *ciphername,
423  const char *authname, bool tls_mode, bool warn);
424 
425 /*
426  * Key context functions
427  */
428 
429 void init_key_ctx(struct key_ctx *ctx, const struct key_parameters *key,
430  const struct key_type *kt, int enc,
431  const char *prefix);
432 
433 void
434 init_key_bi_ctx_send(struct key_ctx *ctx, const struct key_parameters *key,
435  const struct key_type *kt, const char *name);
436 
437 void
438 init_key_bi_ctx_recv(struct key_ctx *ctx, const struct key_parameters *key,
439  const struct key_type *kt, const char *name);
440 
441 void free_key_ctx(struct key_ctx *ctx);
442 
443 void init_key_ctx_bi(struct key_ctx_bi *ctx, const struct key2 *key2,
444  int key_direction, const struct key_type *kt,
445  const char *name);
446 
447 void free_key_ctx_bi(struct key_ctx_bi *ctx);
448 
449 
450 /**************************************************************************/
480 void openvpn_encrypt(struct buffer *buf, struct buffer work,
481  struct crypto_options *opt);
482 
483 
517 bool openvpn_decrypt(struct buffer *buf, struct buffer work,
518  struct crypto_options *opt, const struct frame *frame,
519  const uint8_t *ad_start);
520 
534 bool crypto_check_replay(struct crypto_options *opt,
535  const struct packet_id_net *pin,
536  uint16_t epoch,
537  const char *error_prefix,
538  struct gc_arena *gc);
539 
540 
554 unsigned int
555 calculate_crypto_overhead(const struct key_type *kt,
556  unsigned int pkt_id_size,
557  bool occ);
558 
560 unsigned int crypto_max_overhead(void);
561 
569 void
570 write_pem_key_file(const char *filename, const char *key_name);
571 
579 bool
580 generate_ephemeral_key(struct buffer *key, const char *pem_name);
581 
592 bool
593 read_pem_key_file(struct buffer *key, const char *pem_name,
594  const char *key_file, bool key_inline);
595 
596 /*
597  * Message digest-based pseudo random number generator.
598  *
599  * If the PRNG was initialised with a certain message digest, uses the digest
600  * to calculate the next random number, and prevent depletion of the entropy
601  * pool.
602  *
603  * This PRNG is aimed at IV generation and similar miscellaneous tasks. Use
604  * \c rand_bytes() for higher-assurance functionality.
605  *
606  * Retrieves len bytes of pseudo random data, and places it in output.
607  *
608  * @param output Output buffer
609  * @param len Length of the output buffer
610  */
611 void prng_bytes(uint8_t *output, int len);
612 
613 /* an analogue to the random() function, but use prng_bytes */
614 long int get_random(void);
615 
617 void print_cipher(const char *cipher);
618 
619 void test_crypto(struct crypto_options *co, struct frame *f);
620 
621 
622 /* key direction functions */
623 
624 void key_direction_state_init(struct key_direction_state *kds, int key_direction);
625 
626 void verify_fix_key2(struct key2 *key2, const struct key_type *kt, const char *shared_secret_file);
627 
628 void must_have_n_keys(const char *filename, const char *option, const struct key2 *key2, int n);
629 
630 int ascii2keydirection(int msglevel, const char *str);
631 
632 const char *keydirection2ascii(int kd, bool remote, bool humanreadable);
633 
634 /* print keys */
635 void key2_print(const struct key2 *k,
636  const struct key_type *kt,
637  const char *prefix0,
638  const char *prefix1);
639 
640 void crypto_read_openvpn_key(const struct key_type *key_type,
641  struct key_ctx_bi *ctx, const char *key_file,
642  bool key_inline, const int key_direction,
643  const char *key_name, const char *opt_name,
644  struct key2 *keydata);
645 
646 /*
647  * Inline functions
648  */
649 
654 int memcmp_constant_time(const void *a, const void *b, size_t size);
655 
656 static inline bool
658 {
659  return key->encrypt.cipher || key->encrypt.hmac || key->decrypt.cipher || key->decrypt.hmac;
660 }
661 
672 const char *print_key_filename(const char *str, bool is_inline);
673 
684 static inline struct key_type
685 create_kt(const char *cipher, const char *md, const char *optname)
686 {
687  struct key_type kt;
688  kt.cipher = cipher;
689  kt.digest = md;
690 
691  if (cipher_defined(kt.cipher) && !cipher_valid(kt.cipher))
692  {
693  msg(M_WARN, "ERROR: --%s requires %s support.", optname, kt.cipher);
694  return (struct key_type) { 0 };
695  }
696  if (md_defined(kt.digest) && !md_valid(kt.digest))
697  {
698  msg(M_WARN, "ERROR: --%s requires %s support.", optname, kt.digest);
699  return (struct key_type) { 0 };
700  }
701 
702  return kt;
703 }
704 
714 uint64_t
715 cipher_get_aead_limits(const char *ciphername);
716 
720 static inline bool
722 {
723  /* Use 2**36, same as DTLS 1.3. Strictly speaking this only guarantees
724  * the security margin for packets up to 2^10 blocks (16384 bytes)
725  * but we accept slightly lower security bound for the edge
726  * of Chacha20-Poly1305 and packets over 16k as MTUs over 16k are
727  * extremely rarely used */
728  return ctx->failed_verifications > (1ull << 36);
729 }
730 
735 static inline bool
737 {
738  /* Use 2**35, half the amount after which we refuse to decrypt */
739  return ctx->failed_verifications > (1ull << 35);
740 }
741 
742 
748 #define AEAD_LIMIT_BLOCKSIZE 16
749 
756 bool check_tls_prf_working(void);
757 
764 static inline bool
765 aead_usage_limit_reached(const uint64_t limit, const struct key_ctx *key_ctx,
766  int64_t higest_pid)
767 {
768  /* This is the q + s <= p^(1/2) * 2^(129/2) - 1 calculation where
769  * q is the number of protected messages (highest_pid)
770  * s Total plaintext length in all messages (in blocks) */
771  return (limit > 0 && key_ctx->plaintext_blocks + (uint64_t) higest_pid > limit);
772 }
773 
774 #endif /* CRYPTO_H */
crypto_options::epoch_data_keys_future
struct key_ctx * epoch_data_keys_future
Keeps the future epoch data keys for decryption.
Definition: crypto.h:321
key_direction_state::out_key
int out_key
Index into the key2.keys array for the sending direction.
Definition: crypto.h:259
cipher_valid
static bool cipher_valid(const char *ciphername)
Returns if the cipher is valid, based on the given cipher name.
Definition: crypto_backend.h:205
key2::n
int n
The number of key objects stored in the key2.keys array.
Definition: crypto.h:240
key_parameters::epoch
uint16_t epoch
the epoch of the key.
Definition: crypto.h:178
generate_ephemeral_key
bool generate_ephemeral_key(struct buffer *key, const char *pem_name)
Generate ephermal key material into the key structure.
Definition: crypto.c:1884
packet_id_persist::filename
const char * filename
Definition: packet_id.h:134
hmac_ctx_t
mbedtls_md_context_t hmac_ctx_t
Generic HMAC context.
Definition: crypto_mbedtls.h:48
key2_print
void key2_print(const struct key2 *k, const struct key_type *kt, const char *prefix0, const char *prefix1)
Prints the keys in a key2 structure.
Definition: crypto.c:1208
crypto_options::aead_usage_limit
uint64_t aead_usage_limit
The limit for AEAD cipher, this is the sum of packets + blocks that are allowed to be used.
Definition: crypto.h:312
key_ctx_bi_defined
static bool key_ctx_bi_defined(const struct key_ctx_bi *key)
Definition: crypto.h:657
cipher_defined
static bool cipher_defined(const char *ciphername)
Checks if the cipher is defined and is not the null (none) cipher.
Definition: crypto_backend.h:219
crypto_options::epoch_data_keys_future_count
uint16_t epoch_data_keys_future_count
number of keys stored in epoch_data_keys_future
Definition: crypto.h:324
key_ctx::cipher
cipher_ctx_t * cipher
Generic cipher context.
Definition: crypto.h:202
aead_usage_limit_reached
static bool aead_usage_limit_reached(const uint64_t limit, const struct key_ctx *key_ctx, int64_t higest_pid)
Checks if the usage limit for an AEAD cipher is reached.
Definition: crypto.h:765
key_ctx_bi::encrypt
struct key_ctx encrypt
Cipher and/or HMAC contexts for sending direction.
Definition: crypto.h:280
key_ctx_bi::initialized
bool initialized
Definition: crypto.h:284
cipher_decrypt_verify_fail_warn
static bool cipher_decrypt_verify_fail_warn(const struct key_ctx *ctx)
Check if the number of failed decryption is approaching the limit and we should try to move to a new ...
Definition: crypto.h:736
crypto_options::epoch_retiring_data_receive_key
struct key_ctx epoch_retiring_data_receive_key
The old key before the sender switched to a new epoch data key.
Definition: crypto.h:327
init_key_ctx_bi
void init_key_ctx_bi(struct key_ctx_bi *ctx, const struct key2 *key2, int key_direction, const struct key_type *kt, const char *name)
Definition: crypto.c:1087
key_parameters::hmac_size
int hmac_size
Number of bytes set in the HMac key material.
Definition: crypto.h:173
cipher_get_aead_limits
uint64_t cipher_get_aead_limits(const char *ciphername)
Check if the cipher is an AEAD cipher and needs to be limited to a certain number of number of blocks...
Definition: crypto.c:353
key::hmac
uint8_t hmac[MAX_HMAC_KEY_LENGTH]
Key material for HMAC operations.
Definition: crypto.h:155
frame
Packet geometry parameters.
Definition: mtu.h:98
MAX_CIPHER_KEY_LENGTH
#define MAX_CIPHER_KEY_LENGTH
Definition: crypto_backend.h:178
write_pem_key_file
void write_pem_key_file(const char *filename, const char *key_name)
Generate a server key with enough randomness to fill a key struct and write to file.
Definition: crypto.c:1846
get_random
long int get_random(void)
Definition: crypto.c:1757
key
Container for unidirectional cipher and HMAC key material.
Definition: crypto.h:151
free_key_ctx
void free_key_ctx(struct key_ctx *ctx)
Definition: crypto.c:1106
crypto_options::epoch_key_send
struct epoch_key epoch_key_send
last epoch_key used for generation of the current send data keys.
Definition: crypto.h:301
keydirection2ascii
const char * keydirection2ascii(int kd, bool remote, bool humanreadable)
Definition: crypto.c:1676
packet_id
Definition: packet_id.h:199
key_parameters_from_key
void key_parameters_from_key(struct key_parameters *key_params, const struct key *key)
Converts a struct key representation into a struct key_parameters representation.
Definition: crypto.c:1219
mtu.h
key_ctx::epoch
uint16_t epoch
OpenVPN data channel epoch, this variable holds the epoch number this key belongs to.
Definition: crypto.h:227
print_key_filename
const char * print_key_filename(const char *str, bool is_inline)
To be used when printing a string that may contain inline data.
Definition: crypto.c:1310
key_ctx_bi
Container for two sets of OpenSSL cipher and/or HMAC contexts for both sending and receiving directio...
Definition: crypto.h:278
MAX_HMAC_KEY_LENGTH
#define MAX_HMAC_KEY_LENGTH
Definition: crypto_backend.h:496
key_ctx::failed_verifications
uint64_t failed_verifications
number of failed verification using this cipher
Definition: crypto.h:223
crypto_options::epoch_key_recv
struct epoch_key epoch_key_recv
epoch_key used for the highest receive epoch keys
Definition: crypto.h:304
packet_id.h
key_direction_state
Key ordering of the key2.keys array.
Definition: crypto.h:257
key_type::digest
const char * digest
Message digest static parameters.
Definition: crypto.h:143
cipher_ctx_t
mbedtls_cipher_context_t cipher_ctx_t
Generic cipher context.
Definition: crypto_mbedtls.h:42
packet_id_rec
Definition: packet_id.h:114
M_WARN
#define M_WARN
Definition: error.h:91
ascii2keydirection
int ascii2keydirection(int msglevel, const char *str)
Definition: crypto.c:1653
openvpn_encrypt
void openvpn_encrypt(struct buffer *buf, struct buffer work, struct crypto_options *opt)
Encrypt and HMAC sign a packet so that it can be sent as a data channel VPN tunnel packet to a remote...
Definition: crypto.c:336
key_ctx
Container for one set of cipher and/or HMAC contexts.
Definition: crypto.h:200
crypto_max_overhead
unsigned int crypto_max_overhead(void)
Return the worst-case OpenVPN crypto overhead (in bytes)
Definition: crypto.c:868
key_direction_state::in_key
int in_key
Index into the key2.keys array for the receiving direction.
Definition: crypto.h:261
key_parameters::cipher
uint8_t cipher[MAX_CIPHER_KEY_LENGTH]
Key material for cipher operations.
Definition: crypto.h:164
crypto_read_openvpn_key
void crypto_read_openvpn_key(const struct key_type *key_type, struct key_ctx_bi *ctx, const char *key_file, bool key_inline, const int key_direction, const char *key_name, const char *opt_name, struct key2 *keydata)
Definition: crypto.c:1321
cipher_decrypt_verify_fail_exceeded
static bool cipher_decrypt_verify_fail_exceeded(const struct key_ctx *ctx)
Check if the number of failed decryption is over the acceptable limit.
Definition: crypto.h:721
openvpn_decrypt
bool openvpn_decrypt(struct buffer *buf, struct buffer work, struct crypto_options *opt, const struct frame *frame, const uint8_t *ad_start)
HMAC verify and decrypt a data channel packet received from a remote OpenVPN peer.
Definition: crypto.c:794
buffer
Wrapper structure for dynamically allocated memory.
Definition: buffer.h:60
OPENVPN_MAX_IV_LENGTH
#define OPENVPN_MAX_IV_LENGTH
Maximum length of an IV.
Definition: crypto_mbedtls.h:54
key_ctx::implicit_iv_len
size_t implicit_iv_len
The length of implicit_iv.
Definition: crypto.h:217
test_crypto
void test_crypto(struct crypto_options *co, struct frame *f)
Definition: crypto.c:1229
key_type
Definition: crypto.h:140
must_have_n_keys
void must_have_n_keys(const char *filename, const char *option, const struct key2 *key2, int n)
Definition: crypto.c:1640
key_direction_state::need_keys
int need_keys
The number of key objects necessary to support both sending and receiving.
Definition: crypto.h:263
prng_bytes
void prng_bytes(uint8_t *output, int len)
Definition: crypto.c:1750
buffer.h
key_ctx::implicit_iv
uint8_t implicit_iv[OPENVPN_MAX_IV_LENGTH]
This implicit IV will be always XORed with the packet id that is sent on the wire to get the IV.
Definition: crypto.h:215
create_kt
static struct key_type create_kt(const char *cipher, const char *md, const char *optname)
Creates and validates an instance of struct key_type with the provided algs.
Definition: crypto.h:685
init_key_ctx
void init_key_ctx(struct key_ctx *ctx, const struct key_parameters *key, const struct key_type *kt, int enc, const char *prefix)
Definition: crypto.c:1015
print_cipher
void print_cipher(const char *cipher)
Print a cipher list entry.
Definition: crypto.c:1769
gc_arena
Garbage collection arena used to keep track of dynamically allocated memory.
Definition: buffer.h:116
key_direction_state_init
void key_direction_state_init(struct key_direction_state *kds, int key_direction)
Definition: crypto.c:1705
init_key_bi_ctx_send
void init_key_bi_ctx_send(struct key_ctx *ctx, const struct key_parameters *key, const struct key_type *kt, const char *name)
Definition: crypto.c:1063
sha256_digest::digest
uint8_t digest[SHA256_DIGEST_LENGTH]
Definition: crypto.h:134
key_type::cipher
const char * cipher
const name of the cipher
Definition: crypto.h:142
key_parameters::hmac
uint8_t hmac[MAX_HMAC_KEY_LENGTH]
Key material for HMAC operations.
Definition: crypto.h:170
key_ctx::plaintext_blocks
uint64_t plaintext_blocks
Counter for the number of plaintext block encrypted using this cipher with the current key in number ...
Definition: crypto.h:221
verify_fix_key2
void verify_fix_key2(struct key2 *key2, const struct key_type *kt, const char *shared_secret_file)
Definition: crypto.c:1734
memcmp_constant_time
int memcmp_constant_time(const void *a, const void *b, size_t size)
As memcmp(), but constant-time.
Definition: crypto_openssl.c:1346
key_parameters
internal structure similar to struct key that holds key information but is not represented on wire an...
Definition: crypto.h:162
epoch_key
Definition: crypto.h:191
crypto_check_replay
bool crypto_check_replay(struct crypto_options *opt, const struct packet_id_net *pin, uint16_t epoch, const char *error_prefix, struct gc_arena *gc)
Check packet ID for replay, and perform replay administration.
Definition: crypto.c:384
basic.h
packet_id_persist
Definition: openvpn.h:81
SHA256_DIGEST_LENGTH
#define SHA256_DIGEST_LENGTH
Definition: crypto_mbedtls.h:79
free_key_ctx_bi
void free_key_ctx_bi(struct key_ctx_bi *ctx)
Definition: crypto.c:1125
check_key
bool check_key(struct key *key, const struct key_type *kt)
Definition: crypto.c:1151
md_defined
static bool md_defined(const char *mdname)
Checks if the cipher is defined and is not the null (none) cipher.
Definition: crypto_backend.h:505
calculate_crypto_overhead
unsigned int calculate_crypto_overhead(const struct key_type *kt, unsigned int pkt_id_size, bool occ)
Calculate the maximum overhead that our encryption has on a packet.
Definition: crypto.c:819
epoch_key::epoch
uint16_t epoch
Definition: crypto.h:193
crypto_options::epoch_key_type
struct key_type epoch_key_type
the key_type that is used to generate the epoch keys
Definition: crypto.h:307
key::cipher
uint8_t cipher[MAX_CIPHER_KEY_LENGTH]
Key material for cipher operations.
Definition: crypto.h:153
init_key_type
void init_key_type(struct key_type *kt, const char *ciphername, const char *authname, bool tls_mode, bool warn)
Initialize a key_type structure with.
Definition: crypto.c:893
packet_id_net
Data structure for describing the packet id that is received/send to the network.
Definition: packet_id.h:191
key2
Container for bidirectional cipher and HMAC key material.
Definition: crypto.h:238
crypto_options::epoch_retiring_key_pid_recv
struct packet_id_rec epoch_retiring_key_pid_recv
Definition: crypto.h:328
md_valid
bool md_valid(const char *digest)
Return if a message digest parameters is valid given the name of the digest.
Definition: crypto_openssl.c:1039
sha256_digest
Wrapper struct to pass around SHA256 digests.
Definition: crypto.h:133
write_key_file
int write_key_file(const int nkeys, const char *filename)
Write nkeys 1024-bits keys to file.
Definition: crypto.c:1577
read_pem_key_file
bool read_pem_key_file(struct buffer *key, const char *pem_name, const char *key_file, bool key_inline)
Read key material from a PEM encoded files into the key structure.
Definition: crypto.c:1902
key_ctx::hmac
hmac_ctx_t * hmac
Generic HMAC context.
Definition: crypto.h:203
crypto_options::flags
unsigned int flags
Bit-flags determining behavior of security operation functions.
Definition: crypto.h:383
key2::keys
struct key keys[2]
Two unidirectional sets of key material.
Definition: crypto.h:242
crypto_options::pid_persist
struct packet_id_persist * pid_persist
Persistent packet ID state for keeping state between successive OpenVPN process startups.
Definition: crypto.h:339
init_key_bi_ctx_recv
void init_key_bi_ctx_recv(struct key_ctx *ctx, const struct key_parameters *key, const struct key_type *kt, const char *name)
Definition: crypto.c:1075
msg
#define msg(flags,...)
Definition: error.h:144
key_ctx_bi::decrypt
struct key_ctx decrypt
cipher and/or HMAC contexts for receiving direction.
Definition: crypto.h:282
check_tls_prf_working
bool check_tls_prf_working(void)
Checks if the current TLS library supports the TLS 1.0 PRF with MD5+SHA1 that OpenVPN uses when TLS K...
Definition: crypto.c:1941
http-client.f
string f
Definition: http-client.py:6
crypto_backend.h
read_key_file
void read_key_file(struct key2 *key2, const char *file, const unsigned int flags)
Definition: crypto.c:1373
key_parameters::cipher_size
int cipher_size
Number of bytes set in the cipher key material.
Definition: crypto.h:167
crypto_options
Security parameter state for processing data channel packets.
Definition: crypto.h:291
gc
struct gc_arena gc
Definition: test_ssl.c:155