Branch Coverage

inc/matrixssl-3-9-3-open/crypto/pubkey/rsa.c
Criterion Covered Total %
branch 88 192 45.8


line true false branch
56 0 1057 if (rc < 0)
83 1057 0 if (outlen == SHA256_HASH_SIZE)
87 0 0 else if (outlen == SHA1_HASH_SIZE)
91 0 0 else if (outlen == SHA384_HASH_SIZE)
95 0 0 else if (outlen == SHA512_HASH_SIZE)
106 0 1057 if (front == NULL)
111 0 1057 if ((rc = psRsaDecryptPub(pool, key, in, inlen, c, outlenWithAsn, data)) < 0)
125 0 1057 if (getAsnSequence((const unsigned char **) &c,
132 0 1057 if (getAsnAlgorithmIdentifier((const unsigned char **) &c,
140 1057 0 if (oi == OID_SHA256_ALG)
142 0 1057 psAssert(outlen == SHA256_HASH_SIZE);
144 0 0 else if (oi == OID_SHA1_ALG)
146 0 0 psAssert(outlen == SHA1_HASH_SIZE);
148 0 0 else if (oi == OID_SHA384_ALG)
150 0 0 psAssert(outlen == SHA384_HASH_SIZE);
159 0 0 else if (oi == OID_MD5_ALG)
161 0 0 psAssert(outlen == MD5_HASH_SIZE);
166 0 0 psAssert(outlen == SHA512_HASH_SIZE);
170 1057 0 if ((end - c) < 1 || (*c++ != ASN_OCTET_STRING) ||
171 0 1057 getAsnLength((const unsigned char **) &c, (uint16_t) (end - c), &len) < 0 ||
232 0 1146 if (psRsaEncryptPriv(pool, key, c, inlenWithAsn,
260 0 3541 if (!key)
293 0 128 if ((err = pstm_init_copy(from->pool, &to->N, &from->N, 0)) != PSTM_OKAY)
297 0 128 if ((err = pstm_init_copy(from->pool, &to->e, &from->e, 0)) != PSTM_OKAY)
301 0 128 if ((err = pstm_init_copy(from->pool, &to->d, &from->d, 0)) != PSTM_OKAY)
305 0 128 if ((err = pstm_init_copy(from->pool, &to->p, &from->p, 0)) != PSTM_OKAY)
309 0 128 if ((err = pstm_init_copy(from->pool, &to->q, &from->q, 0)) != PSTM_OKAY)
313 0 128 if ((err = pstm_init_copy(from->pool, &to->dP, &from->dP, 0)) != PSTM_OKAY)
317 0 128 if ((err = pstm_init_copy(from->pool, &to->dQ, &from->dQ, 0)) != PSTM_OKAY)
321 0 128 if ((err = pstm_init_copy(from->pool, &to->qP, &from->qP, 0)) != PSTM_OKAY)
329 0 128 if (err < 0)
413 2774 0 if (len < 1 || (*(p++) != ASN_BIT_STRING) ||
414 2774 0 getAsnLength(&p, len - 1, &keylen) < 0 ||
419 0 2774 if (*p++ != 0)
423 0 2774 if (keylen < 1)
438 0 2774 if (getAsnSequence(&p, keylen, &seqlen) < 0)
517 0 383 if (psRsaInitKey(pool, key) < 0)
522 2 381 if (getAsnSequence(&p, size, &seqlen) < 0)
528 381 0 if (getAsnInteger(&p, (uint16_t) (end - p), &version) < 0 || version != 0 ||
529 251 0 pstm_read_asn(pool, &p, (uint16_t) (end - p), &(key->N)) < 0 ||
530 251 0 pstm_read_asn(pool, &p, (uint16_t) (end - p), &(key->e)) < 0 ||
531 251 0 pstm_read_asn(pool, &p, (uint16_t) (end - p), &(key->d)) < 0 ||
532 251 0 pstm_read_asn(pool, &p, (uint16_t) (end - p), &(key->p)) < 0 ||
533 251 0 pstm_read_asn(pool, &p, (uint16_t) (end - p), &(key->q)) < 0 ||
534 251 0 pstm_read_asn(pool, &p, (uint16_t) (end - p), &(key->dP)) < 0 ||
535 251 0 pstm_read_asn(pool, &p, (uint16_t) (end - p), &(key->dQ)) < 0 ||
536 0 251 pstm_read_asn(pool, &p, (uint16_t) (end - p), &(key->qP)) < 0 ||
573 1 250 if (end != p)
578 8 1 while (p < end)
620 4501 0 if (in == NULL || out == NULL || outlen == NULL || key == NULL)
4501 0 if (in == NULL || out == NULL || outlen == NULL || key == NULL)
4501 0 if (in == NULL || out == NULL || outlen == NULL || key == NULL)
0 4501 if (in == NULL || out == NULL || outlen == NULL || key == NULL)
629 0 4501 if (pstm_init_for_read_unsigned_bin(pool, &tmp, inlen + sizeof(pstm_digit))
634 0 4501 if (pstm_read_unsigned_bin(&tmp, (unsigned char *) in, inlen) != PS_SUCCESS)
640 0 4501 if (pstm_cmp(&key->N, &tmp) == PSTM_LT)
645 1147 3354 if (type == PS_PRIVKEY)
647 1147 0 if (key->optimized)
649 0 1147 if (pstm_init_size(pool, &tmpa, key->p.alloc) != PS_SUCCESS)
654 0 1147 if (pstm_init_size(pool, &tmpb, key->q.alloc) != PS_SUCCESS)
660 0 1147 if (pstm_exptmod(pool, &tmp, &key->dP, &key->p, &tmpa) !=
666 0 1147 if (pstm_exptmod(pool, &tmp, &key->dQ, &key->q, &tmpb) !=
672 0 1147 if (pstm_sub(&tmpa, &tmpb, &tmp) != PS_SUCCESS)
677 0 1147 if (pstm_mulmod(pool, &tmp, &key->qP, &key->p, &tmp) != PS_SUCCESS)
682 0 1147 if (pstm_mul_comba(pool, &tmp, &key->q, &tmp, NULL, 0)
688 0 1147 if (pstm_add(&tmp, &tmpb, &tmp) != PS_SUCCESS)
696 0 0 if (pstm_exptmod(pool, &tmp, &key->d, &key->N, &tmp) !=
704 3354 0 else if (type == PS_PUBKEY)
706 0 3354 if (pstm_exptmod(pool, &tmp, &key->e, &key->N, &tmp) != PS_SUCCESS)
720 0 4501 if ((uint32) x > *outlen)
727 0 4501 while ((uint32) x < (unsigned long) key->size)
737 0 4501 if (pstm_to_unsigned_bin(pool, &tmp, out + (x - pstm_unsigned_bin_size(&tmp)))
749 1147 3354 if (type == PS_PRIVKEY && key->optimized)
1147 0 if (type == PS_PRIVKEY && key->optimized)
783 0 1146 if (inlen < 28)
789 0 1146 if (outlen < size)
795 0 1146 if ((err = pkcs1Pad(in, inlen, out, size, PS_PUBKEY, data)) < PS_SUCCESS)
800 0 1146 if ((err = psRsaCrypt(pool, key, out, size, out, &outlen,
806 0 1146 if (outlen != size)
817 0 1146 if ((verify = psMalloc(pool, inlen)) == NULL)
822 0 1146 if ((tmpout = psMalloc(pool, outlen)) == NULL)
827 0 1146 if (psRsaDecryptPub(pool, key,
832 0 1146 if (memcmpct(in, verify, inlen) != 0)
845 0 0 if (tmpout)
850 0 0 if (verify)
884 0 1 if (outlen < size)
890 0 1 if ((err = pkcs1Pad(in, inlen, out, size, PS_PRIVKEY, data))
896 0 1 if ((err = psRsaCrypt(pool, key, out, size, out, &outlen,
902 0 1 if (outlen != size)
937 0 1 if (inlen != key->size)
943 0 1 if ((err = psRsaCrypt(pool, key, in, inlen, in, &ptLen,
949 0 1 if (ptLen != inlen)
985 0 3353 if (inlen != key->size)
991 0 3353 if ((err = psRsaCrypt(pool, key, in, inlen, in, &ptLen,
997 0 3353 if (ptLen != inlen)
1002 0 3353 if ((err = pkcs1Unpad(in, inlen, out, outlen, PS_PUBKEY)) < 0)