OpenCoverage

rsa_meth.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/rsa/rsa_meth.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* $OpenBSD: rsa_meth.c,v 1.2 2018/09/12 06:35:38 djm Exp $ */-
2/*-
3 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org>-
4 *-
5 * Permission to use, copy, modify, and distribute this software for any-
6 * purpose with or without fee is hereby granted, provided that the above-
7 * copyright notice and this permission notice appear in all copies.-
8 *-
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES-
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF-
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR-
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES-
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN-
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF-
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.-
16 */-
17-
18#include <stdlib.h>-
19#include <string.h>-
20-
21#include <openssl/err.h>-
22#include <openssl/rsa.h>-
23-
24RSA_METHOD *-
25RSA_meth_new(const char *name, int flags)-
26{-
27 RSA_METHOD *meth;-
28-
29 if ((meth = calloc(1, sizeof(*meth))) == NULL)
(meth = calloc...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
30 return NULL;
never executed: return ((void *)0) ;
0
31 if ((meth->name = strdup(name)) == NULL) {
never executed: __retval = (char *) memcpy (__retval, name , __len);
(meth->name = ...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
__retval != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( name )Description
TRUEnever evaluated
FALSEnever evaluated
((size_t)(cons...( name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
32 free(meth);-
33 return NULL;
never executed: return ((void *)0) ;
0
34 }-
35 meth->flags = flags;-
36-
37 return meth;
never executed: return meth;
0
38}-
39-
40void-
41RSA_meth_free(RSA_METHOD *meth)-
42{-
43 if (meth != NULL) {
meth != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • freenull
0-1
44 free((char *)meth->name);-
45 free(meth);-
46 }
never executed: end of block
0
47}
executed 1 time by 1 test: end of block
Executed by:
  • freenull
1
48-
49RSA_METHOD *-
50RSA_meth_dup(const RSA_METHOD *meth)-
51{-
52 RSA_METHOD *copy;-
53-
54 if ((copy = calloc(1, sizeof(*copy))) == NULL)
(copy = calloc...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
55 return NULL;
never executed: return ((void *)0) ;
0
56 memcpy(copy, meth, sizeof(*copy));-
57 if ((copy->name = strdup(meth->name)) == NULL) {
never executed: __retval = (char *) memcpy (__retval, meth->name , __len);
(copy->name = ...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
__retval != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...( meth->name )Description
TRUEnever evaluated
FALSEnever evaluated
((size_t)(cons...->name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
58 free(copy);-
59 return NULL;
never executed: return ((void *)0) ;
0
60 }-
61-
62 return copy;
never executed: return copy;
0
63}-
64-
65int-
66RSA_meth_set1_name(RSA_METHOD *meth, const char *name)-
67{-
68 char *copy;-
69-
70 if ((copy = strdup(name)) == NULL)
never executed: __retval = (char *) memcpy (__retval, name , __len);
(copy = (__ext...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
__retval != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( name )Description
TRUEnever evaluated
FALSEnever evaluated
((size_t)(cons...( name ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
71 return 0;
never executed: return 0;
0
72 free((char *)meth->name);-
73 meth->name = copy;-
74 return 1;
never executed: return 1;
0
75}-
76-
77int-
78(*RSA_meth_get_finish(const RSA_METHOD *meth))(RSA *rsa)-
79{-
80 return meth->finish;
never executed: return meth->finish;
0
81}-
82-
83int-
84RSA_meth_set_priv_enc(RSA_METHOD *meth, int (*priv_enc)(int flen,-
85 const unsigned char *from, unsigned char *to, RSA *rsa, int padding))-
86{-
87 meth->rsa_priv_enc = priv_enc;-
88 return 1;
never executed: return 1;
0
89}-
90-
91int-
92RSA_meth_set_priv_dec(RSA_METHOD *meth, int (*priv_dec)(int flen,-
93 const unsigned char *from, unsigned char *to, RSA *rsa, int padding))-
94{-
95 meth->rsa_priv_dec = priv_dec;-
96 return 1;
never executed: return 1;
0
97}-
98-
99int-
100RSA_meth_set_finish(RSA_METHOD *meth, int (*finish)(RSA *rsa))-
101{-
102 meth->finish = finish;-
103 return 1;
never executed: return 1;
0
104}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2