| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/rsa/rsa_pk1.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | int | - | ||||||||||||||||||
| 4 | RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen, | - | ||||||||||||||||||
| 5 | const unsigned char *from, int flen) | - | ||||||||||||||||||
| 6 | { | - | ||||||||||||||||||
| 7 | int j; | - | ||||||||||||||||||
| 8 | unsigned char *p; | - | ||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | if (flen > (tlen - 11)
| 0-51 | ||||||||||||||||||
| 11 | ERR_put_error(4,(0xfff),(110),__FILE__,75); | - | ||||||||||||||||||
| 12 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 13 | } | - | ||||||||||||||||||
| 14 | - | |||||||||||||||||||
| 15 | p = (unsigned char *)to; | - | ||||||||||||||||||
| 16 | - | |||||||||||||||||||
| 17 | *(p++) = 0; | - | ||||||||||||||||||
| 18 | *(p++) = 1; | - | ||||||||||||||||||
| 19 | - | |||||||||||||||||||
| 20 | - | |||||||||||||||||||
| 21 | j = tlen - 3 - flen; | - | ||||||||||||||||||
| 22 | memset(p, 0xff, j); | - | ||||||||||||||||||
| 23 | p += j; | - | ||||||||||||||||||
| 24 | *(p++) = '\0'; | - | ||||||||||||||||||
| 25 | memcpy(p, from, flen); | - | ||||||||||||||||||
| 26 | - | |||||||||||||||||||
| 27 | return executed 51 times by 5 tests: 1;return 1;Executed by:
executed 51 times by 5 tests: return 1;Executed by:
| 51 | ||||||||||||||||||
| 28 | } | - | ||||||||||||||||||
| 29 | - | |||||||||||||||||||
| 30 | int | - | ||||||||||||||||||
| 31 | RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen, | - | ||||||||||||||||||
| 32 | const unsigned char *from, int flen, int num) | - | ||||||||||||||||||
| 33 | { | - | ||||||||||||||||||
| 34 | int i, j; | - | ||||||||||||||||||
| 35 | const unsigned char *p; | - | ||||||||||||||||||
| 36 | - | |||||||||||||||||||
| 37 | p = from; | - | ||||||||||||||||||
| 38 | if (num != flen + 1
| 0-120 | ||||||||||||||||||
| 39 | ERR_put_error(4,(0xfff),(106),__FILE__,103); | - | ||||||||||||||||||
| 40 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 41 | } | - | ||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | - | |||||||||||||||||||
| 44 | j = flen - 1; | - | ||||||||||||||||||
| 45 | for (i = 0; i < j
| 0-24730 | ||||||||||||||||||
| 46 | if (*
| 120-24610 | ||||||||||||||||||
| 47 | - | |||||||||||||||||||
| 48 | if (*
| 0-120 | ||||||||||||||||||
| 49 | p++; | - | ||||||||||||||||||
| 50 | break; executed 120 times by 3 tests: break;Executed by:
| 120 | ||||||||||||||||||
| 51 | } else { | - | ||||||||||||||||||
| 52 | ERR_put_error(4,(0xfff),(102),__FILE__,116); | - | ||||||||||||||||||
| 53 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 54 | } | - | ||||||||||||||||||
| 55 | } | - | ||||||||||||||||||
| 56 | p++; | - | ||||||||||||||||||
| 57 | } executed 24610 times by 3 tests: end of blockExecuted by:
| 24610 | ||||||||||||||||||
| 58 | - | |||||||||||||||||||
| 59 | if (i == j
| 0-120 | ||||||||||||||||||
| 60 | ERR_put_error(4,(0xfff),(113),__FILE__,124); | - | ||||||||||||||||||
| 61 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 62 | } | - | ||||||||||||||||||
| 63 | - | |||||||||||||||||||
| 64 | if (i < 8
| 0-120 | ||||||||||||||||||
| 65 | ERR_put_error(4,(0xfff),(103),__FILE__,129); | - | ||||||||||||||||||
| 66 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 67 | } | - | ||||||||||||||||||
| 68 | i++; | - | ||||||||||||||||||
| 69 | j -= i; | - | ||||||||||||||||||
| 70 | if (j > tlen
| 0-120 | ||||||||||||||||||
| 71 | ERR_put_error(4,(0xfff),(109),__FILE__,135); | - | ||||||||||||||||||
| 72 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 73 | } | - | ||||||||||||||||||
| 74 | memcpy(to, p, j); | - | ||||||||||||||||||
| 75 | - | |||||||||||||||||||
| 76 | return executed 120 times by 3 tests: j;return j;Executed by:
executed 120 times by 3 tests: return j;Executed by:
| 120 | ||||||||||||||||||
| 77 | } | - | ||||||||||||||||||
| 78 | - | |||||||||||||||||||
| 79 | int | - | ||||||||||||||||||
| 80 | RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen, | - | ||||||||||||||||||
| 81 | const unsigned char *from, int flen) | - | ||||||||||||||||||
| 82 | { | - | ||||||||||||||||||
| 83 | int i, j; | - | ||||||||||||||||||
| 84 | unsigned char *p; | - | ||||||||||||||||||
| 85 | - | |||||||||||||||||||
| 86 | if (flen > tlen - 11
| 0-18 | ||||||||||||||||||
| 87 | ERR_put_error(4,(0xfff),(110),__FILE__,151); | - | ||||||||||||||||||
| 88 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 89 | } | - | ||||||||||||||||||
| 90 | - | |||||||||||||||||||
| 91 | p = (unsigned char *)to; | - | ||||||||||||||||||
| 92 | - | |||||||||||||||||||
| 93 | *(p++) = 0; | - | ||||||||||||||||||
| 94 | *(p++) = 2; | - | ||||||||||||||||||
| 95 | - | |||||||||||||||||||
| 96 | - | |||||||||||||||||||
| 97 | j = tlen - 3 - flen; | - | ||||||||||||||||||
| 98 | - | |||||||||||||||||||
| 99 | arc4random_buf(p, j); | - | ||||||||||||||||||
| 100 | for (i = 0; i < j
| 18-3300 | ||||||||||||||||||
| 101 | while (*
| 8-3300 | ||||||||||||||||||
| 102 | arc4random_buf(p, 1); executed 8 times by 2 tests: arc4random_buf(p, 1);Executed by:
| 8 | ||||||||||||||||||
| 103 | p++; | - | ||||||||||||||||||
| 104 | } executed 3300 times by 3 tests: end of blockExecuted by:
| 3300 | ||||||||||||||||||
| 105 | - | |||||||||||||||||||
| 106 | *(p++) = '\0'; | - | ||||||||||||||||||
| 107 | - | |||||||||||||||||||
| 108 | memcpy(p, from, flen); | - | ||||||||||||||||||
| 109 | return executed 18 times by 3 tests: 1;return 1;Executed by:
executed 18 times by 3 tests: return 1;Executed by:
| 18 | ||||||||||||||||||
| 110 | } | - | ||||||||||||||||||
| 111 | - | |||||||||||||||||||
| 112 | int | - | ||||||||||||||||||
| 113 | RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, | - | ||||||||||||||||||
| 114 | const unsigned char *from, int flen, int num) | - | ||||||||||||||||||
| 115 | { | - | ||||||||||||||||||
| 116 | int i, j; | - | ||||||||||||||||||
| 117 | const unsigned char *p; | - | ||||||||||||||||||
| 118 | - | |||||||||||||||||||
| 119 | p = from; | - | ||||||||||||||||||
| 120 | if (num != flen + 1
| 0-18 | ||||||||||||||||||
| 121 | ERR_put_error(4,(0xfff),(107),__FILE__,185); | - | ||||||||||||||||||
| 122 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 123 | } | - | ||||||||||||||||||
| 124 | - | |||||||||||||||||||
| 125 | - | |||||||||||||||||||
| 126 | j = flen - 1; | - | ||||||||||||||||||
| 127 | for (i = 0; i < j
| 0-3318 | ||||||||||||||||||
| 128 | if (*(
| 18-3300 | ||||||||||||||||||
| 129 | break; executed 18 times by 3 tests: break;Executed by:
| 18 | ||||||||||||||||||
| 130 | - | |||||||||||||||||||
| 131 | if (i == j
| 0-18 | ||||||||||||||||||
| 132 | ERR_put_error(4,(0xfff),(113),__FILE__,196); | - | ||||||||||||||||||
| 133 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 134 | } | - | ||||||||||||||||||
| 135 | - | |||||||||||||||||||
| 136 | if (i < 8
| 0-18 | ||||||||||||||||||
| 137 | ERR_put_error(4,(0xfff),(103),__FILE__,201); | - | ||||||||||||||||||
| 138 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 139 | } | - | ||||||||||||||||||
| 140 | i++; | - | ||||||||||||||||||
| 141 | j -= i; | - | ||||||||||||||||||
| 142 | if (j > tlen
| 0-18 | ||||||||||||||||||
| 143 | ERR_put_error(4,(0xfff),(109),__FILE__,207); | - | ||||||||||||||||||
| 144 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 145 | } | - | ||||||||||||||||||
| 146 | memcpy(to, p, j); | - | ||||||||||||||||||
| 147 | - | |||||||||||||||||||
| 148 | return executed 18 times by 3 tests: j;return j;Executed by:
executed 18 times by 3 tests: return j;Executed by:
| 18 | ||||||||||||||||||
| 149 | } | - | ||||||||||||||||||
| Switch to Source code | Preprocessed file |