ssh_digest_bytes:
  102|    149|{
  103|    149|	const struct ssh_digest *digest = ssh_digest_by_alg(alg);
  104|       |
  105|    149|	return digest == NULL ? 0 : digest->digest_len;
  ------------------
  |  Branch (105:9): [True: 0, False: 149]
  ------------------
  106|    149|}
ssh_digest_memory:
  187|     51|{
  188|     51|	const struct ssh_digest *digest = ssh_digest_by_alg(alg);
  189|     51|	u_int mdlen;
  190|       |
  191|     51|	if (digest == NULL)
  ------------------
  |  Branch (191:6): [True: 0, False: 51]
  ------------------
  192|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  193|     51|	if (dlen > UINT_MAX)
  ------------------
  |  Branch (193:6): [True: 0, False: 51]
  ------------------
  194|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  195|     51|	if (dlen < digest->digest_len)
  ------------------
  |  Branch (195:6): [True: 0, False: 51]
  ------------------
  196|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  197|     51|	mdlen = dlen;
  198|     51|	if (!EVP_Digest(m, mlen, d, &mdlen, digest->mdfunc(), NULL))
  ------------------
  |  Branch (198:6): [True: 0, False: 51]
  ------------------
  199|      0|		return SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  200|     51|	return 0;
  201|     51|}
digest-openssl.c:ssh_digest_by_alg:
   70|    200|{
   71|    200|	if (alg < 0 || alg >= SSH_DIGEST_MAX)
  ------------------
  |  |   31|    200|#define SSH_DIGEST_MAX		6
  ------------------
  |  Branch (71:6): [True: 0, False: 200]
  |  Branch (71:17): [True: 0, False: 200]
  ------------------
   72|      0|		return NULL;
   73|    200|	if (digests[alg].id != alg) /* sanity */
  ------------------
  |  Branch (73:6): [True: 0, False: 200]
  ------------------
   74|      0|		return NULL;
   75|    200|	if (digests[alg].mdfunc == NULL)
  ------------------
  |  Branch (75:6): [True: 0, False: 200]
  ------------------
   76|      0|		return NULL;
   77|    200|	return &(digests[alg]);
   78|    200|}

crypto_sign_ed25519_ref_fe25519_getparity:
  268|     94|{
  269|     94|  fe25519 t = *x;
  ------------------
  |  |   72|     94|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  270|     94|  fe25519_freeze(&t);
  ------------------
  |  |   73|     94|#define fe25519_freeze       crypto_sign_ed25519_ref_fe25519_freeze
  ------------------
  271|     94|  return t.v[0] & 1;
  272|     94|}
crypto_sign_ed25519_ref_unpackneg_vartime:
 1786|     64|{
 1787|     64|  unsigned char par;
 1788|     64|  fe25519 t, chk, num, den, den2, den4, den6;
  ------------------
  |  |   72|     64|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
 1789|     64|  fe25519_setone(&r->z);
  ------------------
  |  |   79|     64|#define fe25519_setone       crypto_sign_ed25519_ref_fe25519_setone
  ------------------
 1790|     64|  par = p[31] >> 7;
 1791|     64|  fe25519_unpack(&r->y, p);
  ------------------
  |  |   74|     64|#define fe25519_unpack       crypto_sign_ed25519_ref_fe25519_unpack
  ------------------
 1792|     64|  fe25519_square(&num, &r->y); /* x = y^2 */
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
 1793|     64|  fe25519_mul(&den, &num, &ge25519_ecd); /* den = dy^2 */
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1794|     64|  fe25519_sub(&num, &num, &r->z); /* x = y^2-1 */
  ------------------
  |  |   84|     64|#define fe25519_sub          crypto_sign_ed25519_ref_fe25519_sub
  ------------------
 1795|     64|  fe25519_add(&den, &r->z, &den); /* den = dy^2+1 */
  ------------------
  |  |   83|     64|#define fe25519_add          crypto_sign_ed25519_ref_fe25519_add
  ------------------
 1796|       |
 1797|       |  /* Computation of sqrt(num/den) */
 1798|       |  /* 1.: computation of num^((p-5)/8)*den^((7p-35)/8) = (num*den^7)^((p-5)/8) */
 1799|     64|  fe25519_square(&den2, &den);
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
 1800|     64|  fe25519_square(&den4, &den2);
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
 1801|     64|  fe25519_mul(&den6, &den4, &den2);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1802|     64|  fe25519_mul(&t, &den6, &num);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1803|     64|  fe25519_mul(&t, &t, &den);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1804|       |
 1805|     64|  fe25519_pow2523(&t, &t);
  ------------------
  |  |   88|     64|#define fe25519_pow2523      crypto_sign_ed25519_ref_fe25519_pow2523
  ------------------
 1806|       |  /* 2. computation of r->x = t * num * den^3 */
 1807|     64|  fe25519_mul(&t, &t, &num);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1808|     64|  fe25519_mul(&t, &t, &den);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1809|     64|  fe25519_mul(&t, &t, &den);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1810|     64|  fe25519_mul(&r->x, &t, &den);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1811|       |
 1812|       |  /* 3. Check whether sqrt computation gave correct result, multiply by sqrt(-1) if not: */
 1813|     64|  fe25519_square(&chk, &r->x);
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
 1814|     64|  fe25519_mul(&chk, &chk, &den);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1815|     64|  if (!fe25519_iseq_vartime(&chk, &num))
  ------------------
  |  |   77|     64|#define fe25519_iseq_vartime crypto_sign_ed25519_ref_fe25519_iseq_vartime
  ------------------
  |  Branch (1815:7): [True: 42, False: 22]
  ------------------
 1816|     42|    fe25519_mul(&r->x, &r->x, &ge25519_sqrtm1);
  ------------------
  |  |   85|     42|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1817|       |
 1818|       |  /* 4. Now we have one of the two square roots, except if input was not a square */
 1819|     64|  fe25519_square(&chk, &r->x);
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
 1820|     64|  fe25519_mul(&chk, &chk, &den);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1821|     64|  if (!fe25519_iseq_vartime(&chk, &num))
  ------------------
  |  |   77|     64|#define fe25519_iseq_vartime crypto_sign_ed25519_ref_fe25519_iseq_vartime
  ------------------
  |  Branch (1821:7): [True: 17, False: 47]
  ------------------
 1822|     17|    return -1;
 1823|       |
 1824|       |  /* 5. Choose the desired square root according to parity: */
 1825|     47|  if(fe25519_getparity(&r->x) != (1-par))
  ------------------
  |  |   82|     47|#define fe25519_getparity    crypto_sign_ed25519_ref_fe25519_getparity
  ------------------
  |  Branch (1825:6): [True: 25, False: 22]
  ------------------
 1826|     25|    fe25519_neg(&r->x, &r->x);
  ------------------
  |  |   81|     25|#define fe25519_neg          crypto_sign_ed25519_ref_fe25519_neg
  ------------------
 1827|       |
 1828|     47|  fe25519_mul(&r->t, &r->x, &r->y);
  ------------------
  |  |   85|     47|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1829|     47|  return 0;
 1830|     64|}
crypto_sign_ed25519_open:
 1993|     82|{
 1994|     82|  unsigned char pkcopy[32];
 1995|     82|  unsigned char rcopy[32];
 1996|     82|  unsigned char hram[64];
 1997|     82|  unsigned char rcheck[32];
 1998|     82|  ge25519 get1, get2;
  ------------------
  |  |  724|     82|#define ge25519                           crypto_sign_ed25519_ref_ge25519
  ------------------
 1999|     82|  sc25519 schram, scs;
  ------------------
  |  |  461|     82|#define sc25519                  crypto_sign_ed25519_ref_sc25519
  ------------------
 2000|       |
 2001|     82|  if (smlen < 64) goto badsig;
  ------------------
  |  Branch (2001:7): [True: 0, False: 82]
  ------------------
 2002|     82|  if (sm[63] & 224) goto badsig;
  ------------------
  |  Branch (2002:7): [True: 18, False: 64]
  ------------------
 2003|     64|  if (ge25519_unpackneg_vartime(&get1,pk)) goto badsig;
  ------------------
  |  |  726|     64|#define ge25519_unpackneg_vartime         crypto_sign_ed25519_ref_unpackneg_vartime
  ------------------
  |  Branch (2003:7): [True: 17, False: 47]
  ------------------
 2004|       |
 2005|     47|  memmove(pkcopy,pk,32);
 2006|     47|  memmove(rcopy,sm,32);
 2007|       |
 2008|     47|  sc25519_from32bytes(&scs, sm+32);
  ------------------
  |  |  463|     47|#define sc25519_from32bytes      crypto_sign_ed25519_ref_sc25519_from32bytes
  ------------------
 2009|       |
 2010|     47|  memmove(m,sm,smlen);
 2011|     47|  memmove(m + 32,pkcopy,32);
 2012|     47|  crypto_hash_sha512(hram,m,smlen);
 2013|       |
 2014|     47|  sc25519_from64bytes(&schram, hram);
  ------------------
  |  |  464|     47|#define sc25519_from64bytes      crypto_sign_ed25519_ref_sc25519_from64bytes
  ------------------
 2015|       |
 2016|     47|  ge25519_double_scalarmult_vartime(&get2, &get1, &schram, &ge25519_base, &scs);
  ------------------
  |  |  729|     47|#define ge25519_double_scalarmult_vartime crypto_sign_ed25519_ref_double_scalarmult_vartime
  ------------------
                ge25519_double_scalarmult_vartime(&get2, &get1, &schram, &ge25519_base, &scs);
  ------------------
  |  |  725|     47|#define ge25519_base                      crypto_sign_ed25519_ref_ge25519_base
  ------------------
 2017|     47|  ge25519_pack(rcheck, &get2);
  ------------------
  |  |  727|     47|#define ge25519_pack                      crypto_sign_ed25519_ref_pack
  ------------------
 2018|       |
 2019|     47|  if (crypto_verify_32(rcopy,rcheck) == 0) {
  ------------------
  |  Branch (2019:7): [True: 1, False: 46]
  ------------------
 2020|      1|    memmove(m,m + 64,smlen - 64);
 2021|      1|    memset(m + smlen - 64,0,64);
 2022|      1|    *mlen = smlen - 64;
 2023|      1|    return 0;
 2024|      1|  }
 2025|       |
 2026|     81|badsig:
 2027|     81|  *mlen = (unsigned long long) -1;
 2028|     81|  memset(m,0,smlen);
 2029|     81|  return -1;
 2030|     47|}
ed25519.c:crypto_sign_ed25519_ref_fe25519_freeze:
  203|    397|{
  204|    397|  int i;
  205|    397|  crypto_uint32 m = fe25519_equal(r->v[31],127);
  206|  12.3k|  for(i=30;i>0;i--)
  ------------------
  |  Branch (206:12): [True: 11.9k, False: 397]
  ------------------
  207|  11.9k|    m &= fe25519_equal(r->v[i],255);
  208|    397|  m &= ge(r->v[0],237);
  209|       |
  210|    397|  m = -m;
  211|       |
  212|    397|  r->v[31] -= m&127;
  213|  12.3k|  for(i=30;i>0;i--)
  ------------------
  |  Branch (213:12): [True: 11.9k, False: 397]
  ------------------
  214|  11.9k|    r->v[i] -= m&255;
  215|    397|  r->v[0] -= m&237;
  216|    397|}
ed25519.c:fe25519_equal:
  135|  12.3k|{
  136|  12.3k|  crypto_uint32 x = a ^ b; /* 0: yes; 1..65535: no */
  137|  12.3k|  x -= 1; /* 4294967295: yes; 0..65534: no */
  138|  12.3k|  x >>= 31; /* 1: yes; 0: no */
  139|  12.3k|  return x;
  140|  12.3k|}
ed25519.c:ge:
  143|    397|{
  144|    397|  unsigned int x = a;
  145|    397|  x -= (unsigned int) b; /* 0..65535: yes; 4294901761..4294967295: no */
  146|    397|  x >>= 31; /* 0: yes; 1: no */
  147|    397|  x ^= 1; /* 1: yes; 0: no */
  148|    397|  return x;
  149|    397|}
ed25519.c:crypto_sign_ed25519_ref_fe25519_setone:
  275|    158|{
  276|    158|  int i;
  277|    158|  r->v[0] = 1;
  278|  5.05k|  for(i=1;i<32;i++) r->v[i]=0;
  ------------------
  |  Branch (278:11): [True: 4.89k, False: 158]
  ------------------
  279|    158|}
ed25519.c:crypto_sign_ed25519_ref_fe25519_unpack:
  219|     64|{
  220|     64|  int i;
  221|  2.11k|  for(i=0;i<32;i++) r->v[i] = x[i];
  ------------------
  |  Branch (221:11): [True: 2.04k, False: 64]
  ------------------
  222|     64|  r->v[31] &= 127;
  223|     64|}
ed25519.c:crypto_sign_ed25519_ref_fe25519_square:
  332|  76.2k|{
  333|  76.2k|  fe25519_mul(r, x, x);
  ------------------
  |  |   85|  76.2k|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  334|  76.2k|}
ed25519.c:crypto_sign_ed25519_ref_fe25519_mul:
  315|   161k|{
  316|   161k|  int i,j;
  317|   161k|  crypto_uint32 t[63];
  318|  10.3M|  for(i=0;i<63;i++)t[i] = 0;
  ------------------
  |  Branch (318:11): [True: 10.1M, False: 161k]
  ------------------
  319|       |
  320|  5.33M|  for(i=0;i<32;i++)
  ------------------
  |  Branch (320:11): [True: 5.16M, False: 161k]
  ------------------
  321|   170M|    for(j=0;j<32;j++)
  ------------------
  |  Branch (321:13): [True: 165M, False: 5.16M]
  ------------------
  322|   165M|      t[i+j] += x->v[i] * y->v[j];
  323|       |
  324|  5.16M|  for(i=32;i<63;i++)
  ------------------
  |  Branch (324:12): [True: 5.00M, False: 161k]
  ------------------
  325|  5.00M|    r->v[i-32] = t[i-32] + times38(t[i]);
  326|   161k|  r->v[31] = t[31]; /* result now in r[0]...r[31] */
  327|       |
  328|   161k|  reduce_mul(r);
  329|   161k|}
ed25519.c:times38:
  157|  5.00M|{
  158|  5.00M|  return (a << 5) + (a << 2) + (a << 1);
  159|  5.00M|}
ed25519.c:reduce_mul:
  182|   161k|{
  183|   161k|  crypto_uint32 t;
  184|   161k|  int i,rep;
  185|       |
  186|   484k|  for(rep=0;rep<2;rep++)
  ------------------
  |  Branch (186:13): [True: 323k, False: 161k]
  ------------------
  187|   323k|  {
  188|   323k|    t = r->v[31] >> 7;
  189|   323k|    r->v[31] &= 127;
  190|   323k|    t = times19(t);
  191|   323k|    r->v[0] += t;
  192|  10.3M|    for(i=0;i<31;i++)
  ------------------
  |  Branch (192:13): [True: 10.0M, False: 323k]
  ------------------
  193|  10.0M|    {
  194|  10.0M|      t = r->v[i] >> 8;
  195|  10.0M|      r->v[i+1] += t;
  196|  10.0M|      r->v[i] &= 255;
  197|  10.0M|    }
  198|   323k|  }
  199|   161k|}
ed25519.c:times19:
  152|   895k|{
  153|   895k|  return (a << 4) + (a << 1) + a;
  154|   895k|}
ed25519.c:crypto_sign_ed25519_ref_fe25519_sub:
  304|  80.9k|{
  305|  80.9k|  int i;
  306|  80.9k|  crypto_uint32 t[32];
  307|  80.9k|  t[0] = x->v[0] + 0x1da;
  308|  80.9k|  t[31] = x->v[31] + 0xfe;
  309|  2.50M|  for(i=1;i<31;i++) t[i] = x->v[i] + 0x1fe;
  ------------------
  |  Branch (309:11): [True: 2.42M, False: 80.9k]
  ------------------
  310|  2.67M|  for(i=0;i<32;i++) r->v[i] = t[i] - y->v[i];
  ------------------
  |  Branch (310:11): [True: 2.59M, False: 80.9k]
  ------------------
  311|  80.9k|  fe25519_reduce_add_sub(r);
  312|  80.9k|}
ed25519.c:fe25519_reduce_add_sub:
  162|   143k|{
  163|   143k|  crypto_uint32 t;
  164|   143k|  int i,rep;
  165|       |
  166|   715k|  for(rep=0;rep<4;rep++)
  ------------------
  |  Branch (166:13): [True: 572k, False: 143k]
  ------------------
  167|   572k|  {
  168|   572k|    t = r->v[31] >> 7;
  169|   572k|    r->v[31] &= 127;
  170|   572k|    t = times19(t);
  171|   572k|    r->v[0] += t;
  172|  18.3M|    for(i=0;i<31;i++)
  ------------------
  |  Branch (172:13): [True: 17.7M, False: 572k]
  ------------------
  173|  17.7M|    {
  174|  17.7M|      t = r->v[i] >> 8;
  175|  17.7M|      r->v[i+1] += t;
  176|  17.7M|      r->v[i] &= 255;
  177|  17.7M|    }
  178|   572k|  }
  179|   143k|}
ed25519.c:crypto_sign_ed25519_ref_fe25519_add:
  297|  62.1k|{
  298|  62.1k|  int i;
  299|  2.05M|  for(i=0;i<32;i++) r->v[i] = x->v[i] + y->v[i];
  ------------------
  |  Branch (299:11): [True: 1.99M, False: 62.1k]
  ------------------
  300|  62.1k|  fe25519_reduce_add_sub(r);
  301|  62.1k|}
ed25519.c:crypto_sign_ed25519_ref_fe25519_pow2523:
  404|     64|{
  405|     64|	fe25519 z2;
  ------------------
  |  |   72|     64|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  406|     64|	fe25519 z9;
  ------------------
  |  |   72|     64|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  407|     64|	fe25519 z11;
  ------------------
  |  |   72|     64|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  408|     64|	fe25519 z2_5_0;
  ------------------
  |  |   72|     64|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  409|     64|	fe25519 z2_10_0;
  ------------------
  |  |   72|     64|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  410|     64|	fe25519 z2_20_0;
  ------------------
  |  |   72|     64|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  411|     64|	fe25519 z2_50_0;
  ------------------
  |  |   72|     64|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  412|     64|	fe25519 z2_100_0;
  ------------------
  |  |   72|     64|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  413|     64|	fe25519 t;
  ------------------
  |  |   72|     64|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  414|     64|	int i;
  415|       |
  416|     64|	/* 2 */ fe25519_square(&z2,x);
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  417|       |	/* 4 */ fe25519_square(&t,&z2);
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  418|       |	/* 8 */ fe25519_square(&t,&t);
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  419|       |	/* 9 */ fe25519_mul(&z9,&t,x);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  420|       |	/* 11 */ fe25519_mul(&z11,&z9,&z2);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  421|       |	/* 22 */ fe25519_square(&t,&z11);
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  422|       |	/* 2^5 - 2^0 = 31 */ fe25519_mul(&z2_5_0,&t,&z9);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  423|       |
  424|     64|	/* 2^6 - 2^1 */ fe25519_square(&t,&z2_5_0);
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  425|    320|	/* 2^10 - 2^5 */ for (i = 1;i < 5;i++) { fe25519_square(&t,&t); }
  ------------------
  |  |   86|    256|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  |  Branch (425:30): [True: 256, False: 64]
  ------------------
  426|       |	/* 2^10 - 2^0 */ fe25519_mul(&z2_10_0,&t,&z2_5_0);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  427|       |
  428|     64|	/* 2^11 - 2^1 */ fe25519_square(&t,&z2_10_0);
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  429|    640|	/* 2^20 - 2^10 */ for (i = 1;i < 10;i++) { fe25519_square(&t,&t); }
  ------------------
  |  |   86|    576|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  |  Branch (429:31): [True: 576, False: 64]
  ------------------
  430|       |	/* 2^20 - 2^0 */ fe25519_mul(&z2_20_0,&t,&z2_10_0);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  431|       |
  432|     64|	/* 2^21 - 2^1 */ fe25519_square(&t,&z2_20_0);
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  433|  1.28k|	/* 2^40 - 2^20 */ for (i = 1;i < 20;i++) { fe25519_square(&t,&t); }
  ------------------
  |  |   86|  1.21k|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  |  Branch (433:31): [True: 1.21k, False: 64]
  ------------------
  434|       |	/* 2^40 - 2^0 */ fe25519_mul(&t,&t,&z2_20_0);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  435|       |
  436|     64|	/* 2^41 - 2^1 */ fe25519_square(&t,&t);
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  437|    640|	/* 2^50 - 2^10 */ for (i = 1;i < 10;i++) { fe25519_square(&t,&t); }
  ------------------
  |  |   86|    576|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  |  Branch (437:31): [True: 576, False: 64]
  ------------------
  438|       |	/* 2^50 - 2^0 */ fe25519_mul(&z2_50_0,&t,&z2_10_0);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  439|       |
  440|     64|	/* 2^51 - 2^1 */ fe25519_square(&t,&z2_50_0);
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  441|  3.20k|	/* 2^100 - 2^50 */ for (i = 1;i < 50;i++) { fe25519_square(&t,&t); }
  ------------------
  |  |   86|  3.13k|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  |  Branch (441:32): [True: 3.13k, False: 64]
  ------------------
  442|       |	/* 2^100 - 2^0 */ fe25519_mul(&z2_100_0,&t,&z2_50_0);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  443|       |
  444|     64|	/* 2^101 - 2^1 */ fe25519_square(&t,&z2_100_0);
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  445|  6.40k|	/* 2^200 - 2^100 */ for (i = 1;i < 100;i++) { fe25519_square(&t,&t); }
  ------------------
  |  |   86|  6.33k|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  |  Branch (445:33): [True: 6.33k, False: 64]
  ------------------
  446|       |	/* 2^200 - 2^0 */ fe25519_mul(&t,&t,&z2_100_0);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  447|       |
  448|     64|	/* 2^201 - 2^1 */ fe25519_square(&t,&t);
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  449|  3.20k|	/* 2^250 - 2^50 */ for (i = 1;i < 50;i++) { fe25519_square(&t,&t); }
  ------------------
  |  |   86|  3.13k|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  |  Branch (449:32): [True: 3.13k, False: 64]
  ------------------
  450|       |	/* 2^250 - 2^0 */ fe25519_mul(&t,&t,&z2_50_0);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  451|       |
  452|     64|	/* 2^251 - 2^1 */ fe25519_square(&t,&t);
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  453|       |	/* 2^252 - 2^2 */ fe25519_square(&t,&t);
  ------------------
  |  |   86|     64|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  454|       |	/* 2^252 - 3 */ fe25519_mul(r,&t,x);
  ------------------
  |  |   85|     64|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  455|     64|}
ed25519.c:crypto_sign_ed25519_ref_fe25519_iseq_vartime:
  248|    128|{
  249|    128|  int i;
  250|    128|  fe25519 t1 = *x;
  ------------------
  |  |   72|    128|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  251|    128|  fe25519 t2 = *y;
  ------------------
  |  |   72|    128|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  252|    128|  fe25519_freeze(&t1);
  ------------------
  |  |   73|    128|#define fe25519_freeze       crypto_sign_ed25519_ref_fe25519_freeze
  ------------------
  253|    128|  fe25519_freeze(&t2);
  ------------------
  |  |   73|    128|#define fe25519_freeze       crypto_sign_ed25519_ref_fe25519_freeze
  ------------------
  254|  2.34k|  for(i=0;i<32;i++)
  ------------------
  |  Branch (254:11): [True: 2.27k, False: 69]
  ------------------
  255|  2.27k|    if(t1.v[i] != t2.v[i]) return 0;
  ------------------
  |  Branch (255:8): [True: 59, False: 2.21k]
  ------------------
  256|     69|  return 1;
  257|    128|}
ed25519.c:crypto_sign_ed25519_ref_fe25519_neg:
  288|  12.0k|{
  289|  12.0k|  fe25519 t;
  ------------------
  |  |   72|  12.0k|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  290|  12.0k|  int i;
  291|   396k|  for(i=0;i<32;i++) t.v[i]=x->v[i];
  ------------------
  |  Branch (291:11): [True: 384k, False: 12.0k]
  ------------------
  292|  12.0k|  fe25519_setzero(r);
  ------------------
  |  |   80|  12.0k|#define fe25519_setzero      crypto_sign_ed25519_ref_fe25519_setzero
  ------------------
  293|  12.0k|  fe25519_sub(r, r, &t);
  ------------------
  |  |   84|  12.0k|#define fe25519_sub          crypto_sign_ed25519_ref_fe25519_sub
  ------------------
  294|  12.0k|}
ed25519.c:crypto_sign_ed25519_ref_fe25519_setzero:
  282|  12.1k|{
  283|  12.1k|  int i;
  284|   399k|  for(i=0;i<32;i++) r->v[i]=0;
  ------------------
  |  Branch (284:11): [True: 387k, False: 12.1k]
  ------------------
  285|  12.1k|}
ed25519.c:crypto_sign_ed25519_ref_sc25519_from32bytes:
  604|     47|{
  605|     47|  int i;
  606|     47|  crypto_uint32 t[64];
  607|  1.55k|  for(i=0;i<32;i++) t[i] = x[i];
  ------------------
  |  Branch (607:11): [True: 1.50k, False: 47]
  ------------------
  608|  1.55k|  for(i=32;i<64;++i) t[i] = 0;
  ------------------
  |  Branch (608:12): [True: 1.50k, False: 47]
  ------------------
  609|     47|  barrett_reduce(r, t);
  610|     47|}
ed25519.c:barrett_reduce:
  553|     94|{
  554|       |  /* See HAC, Alg. 14.42 */
  555|     94|  int i,j;
  556|     94|  crypto_uint32 q2[66];
  557|     94|  crypto_uint32 *q3 = q2 + 33;
  558|     94|  crypto_uint32 r1[33];
  559|     94|  crypto_uint32 r2[33];
  560|     94|  crypto_uint32 carry;
  561|     94|  crypto_uint32 pb = 0;
  562|     94|  crypto_uint32 b;
  563|       |
  564|  6.29k|  for (i = 0;i < 66;++i) q2[i] = 0;
  ------------------
  |  Branch (564:14): [True: 6.20k, False: 94]
  ------------------
  565|  3.19k|  for (i = 0;i < 33;++i) r2[i] = 0;
  ------------------
  |  Branch (565:14): [True: 3.10k, False: 94]
  ------------------
  566|       |
  567|  3.19k|  for(i=0;i<33;i++)
  ------------------
  |  Branch (567:11): [True: 3.10k, False: 94]
  ------------------
  568|   105k|    for(j=0;j<33;j++)
  ------------------
  |  Branch (568:13): [True: 102k, False: 3.10k]
  ------------------
  569|   102k|      if(i+j >= 31) q2[i+j] += sc25519_mu[i]*x[j+31];
  ------------------
  |  Branch (569:10): [True: 55.7k, False: 46.6k]
  ------------------
  570|     94|  carry = q2[31] >> 8;
  571|     94|  q2[32] += carry;
  572|     94|  carry = q2[32] >> 8;
  573|     94|  q2[33] += carry;
  574|       |
  575|  3.19k|  for(i=0;i<33;i++)r1[i] = x[i];
  ------------------
  |  Branch (575:11): [True: 3.10k, False: 94]
  ------------------
  576|  3.10k|  for(i=0;i<32;i++)
  ------------------
  |  Branch (576:11): [True: 3.00k, False: 94]
  ------------------
  577|   102k|    for(j=0;j<33;j++)
  ------------------
  |  Branch (577:13): [True: 99.2k, False: 3.00k]
  ------------------
  578|  99.2k|      if(i+j < 33) r2[i+j] += sc25519_m[i]*q3[j];
  ------------------
  |  Branch (578:10): [True: 52.6k, False: 46.6k]
  ------------------
  579|       |
  580|  3.10k|  for(i=0;i<32;i++)
  ------------------
  |  Branch (580:11): [True: 3.00k, False: 94]
  ------------------
  581|  3.00k|  {
  582|  3.00k|    carry = r2[i] >> 8;
  583|  3.00k|    r2[i+1] += carry;
  584|  3.00k|    r2[i] &= 0xff;
  585|  3.00k|  }
  586|       |
  587|  3.10k|  for(i=0;i<32;i++)
  ------------------
  |  Branch (587:11): [True: 3.00k, False: 94]
  ------------------
  588|  3.00k|  {
  589|  3.00k|    pb += r2[i];
  590|  3.00k|    b = lt(r1[i],pb);
  591|  3.00k|    r->v[i] = r1[i]-pb+(b<<8);
  592|  3.00k|    pb = b;
  593|  3.00k|  }
  594|       |
  595|       |  /* XXX: Can it really happen that r<0?, See HAC, Alg 14.42, Step 3
  596|       |   * If so: Handle  it here!
  597|       |   */
  598|       |
  599|     94|  sc25519_reduce_add_sub(r);
  600|     94|  sc25519_reduce_add_sub(r);
  601|     94|}
ed25519.c:lt:
  523|  9.02k|{
  524|  9.02k|  unsigned int x = a;
  525|  9.02k|  x -= (unsigned int) b; /* 0..65535: no; 4294901761..4294967295: yes */
  526|  9.02k|  x >>= 31; /* 0: no; 1: yes */
  527|  9.02k|  return x;
  528|  9.02k|}
ed25519.c:sc25519_reduce_add_sub:
  532|    188|{
  533|    188|  crypto_uint32 pb = 0;
  534|    188|  crypto_uint32 b;
  535|    188|  crypto_uint32 mask;
  536|    188|  int i;
  537|    188|  unsigned char t[32];
  538|       |
  539|  6.20k|  for(i=0;i<32;i++)
  ------------------
  |  Branch (539:11): [True: 6.01k, False: 188]
  ------------------
  540|  6.01k|  {
  541|  6.01k|    pb += sc25519_m[i];
  542|  6.01k|    b = lt(r->v[i],pb);
  543|  6.01k|    t[i] = r->v[i]-pb+(b<<8);
  544|  6.01k|    pb = b;
  545|  6.01k|  }
  546|    188|  mask = b - 1;
  547|  6.20k|  for(i=0;i<32;i++)
  ------------------
  |  Branch (547:11): [True: 6.01k, False: 188]
  ------------------
  548|  6.01k|    r->v[i] ^= mask & (r->v[i] ^ t[i]);
  549|    188|}
ed25519.c:crypto_sign_ed25519_ref_pack:
 1833|     47|{
 1834|     47|  fe25519 tx, ty, zi;
  ------------------
  |  |   72|     47|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
 1835|     47|  fe25519_invert(&zi, &p->z);
  ------------------
  |  |   87|     47|#define fe25519_invert       crypto_sign_ed25519_ref_fe25519_invert
  ------------------
 1836|     47|  fe25519_mul(&tx, &p->x, &zi);
  ------------------
  |  |   85|     47|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1837|     47|  fe25519_mul(&ty, &p->y, &zi);
  ------------------
  |  |   85|     47|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1838|     47|  fe25519_pack(r, &ty);
  ------------------
  |  |   75|     47|#define fe25519_pack         crypto_sign_ed25519_ref_fe25519_pack
  ------------------
 1839|     47|  r[31] ^= fe25519_getparity(&tx) << 7;
  ------------------
  |  |   82|     47|#define fe25519_getparity    crypto_sign_ed25519_ref_fe25519_getparity
  ------------------
 1840|     47|}
ed25519.c:crypto_sign_ed25519_ref_fe25519_invert:
  337|     47|{
  338|     47|	fe25519 z2;
  ------------------
  |  |   72|     47|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  339|     47|	fe25519 z9;
  ------------------
  |  |   72|     47|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  340|     47|	fe25519 z11;
  ------------------
  |  |   72|     47|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  341|     47|	fe25519 z2_5_0;
  ------------------
  |  |   72|     47|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  342|     47|	fe25519 z2_10_0;
  ------------------
  |  |   72|     47|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  343|     47|	fe25519 z2_20_0;
  ------------------
  |  |   72|     47|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  344|     47|	fe25519 z2_50_0;
  ------------------
  |  |   72|     47|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  345|     47|	fe25519 z2_100_0;
  ------------------
  |  |   72|     47|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  346|     47|	fe25519 t0;
  ------------------
  |  |   72|     47|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  347|     47|	fe25519 t1;
  ------------------
  |  |   72|     47|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  348|     47|	int i;
  349|       |
  350|     47|	/* 2 */ fe25519_square(&z2,x);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  351|       |	/* 4 */ fe25519_square(&t1,&z2);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  352|       |	/* 8 */ fe25519_square(&t0,&t1);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  353|       |	/* 9 */ fe25519_mul(&z9,&t0,x);
  ------------------
  |  |   85|     47|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  354|       |	/* 11 */ fe25519_mul(&z11,&z9,&z2);
  ------------------
  |  |   85|     47|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  355|       |	/* 22 */ fe25519_square(&t0,&z11);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  356|       |	/* 2^5 - 2^0 = 31 */ fe25519_mul(&z2_5_0,&t0,&z9);
  ------------------
  |  |   85|     47|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  357|       |
  358|     47|	/* 2^6 - 2^1 */ fe25519_square(&t0,&z2_5_0);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  359|       |	/* 2^7 - 2^2 */ fe25519_square(&t1,&t0);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  360|       |	/* 2^8 - 2^3 */ fe25519_square(&t0,&t1);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  361|       |	/* 2^9 - 2^4 */ fe25519_square(&t1,&t0);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  362|       |	/* 2^10 - 2^5 */ fe25519_square(&t0,&t1);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  363|       |	/* 2^10 - 2^0 */ fe25519_mul(&z2_10_0,&t0,&z2_5_0);
  ------------------
  |  |   85|     47|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  364|       |
  365|     47|	/* 2^11 - 2^1 */ fe25519_square(&t0,&z2_10_0);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  366|       |	/* 2^12 - 2^2 */ fe25519_square(&t1,&t0);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  367|    235|	/* 2^20 - 2^10 */ for (i = 2;i < 10;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); }
  ------------------
  |  |   86|    188|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
              	/* 2^20 - 2^10 */ for (i = 2;i < 10;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); }
  ------------------
  |  |   86|    188|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  |  Branch (367:31): [True: 188, False: 47]
  ------------------
  368|       |	/* 2^20 - 2^0 */ fe25519_mul(&z2_20_0,&t1,&z2_10_0);
  ------------------
  |  |   85|     47|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  369|       |
  370|     47|	/* 2^21 - 2^1 */ fe25519_square(&t0,&z2_20_0);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  371|       |	/* 2^22 - 2^2 */ fe25519_square(&t1,&t0);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  372|    470|	/* 2^40 - 2^20 */ for (i = 2;i < 20;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); }
  ------------------
  |  |   86|    423|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
              	/* 2^40 - 2^20 */ for (i = 2;i < 20;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); }
  ------------------
  |  |   86|    423|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  |  Branch (372:31): [True: 423, False: 47]
  ------------------
  373|       |	/* 2^40 - 2^0 */ fe25519_mul(&t0,&t1,&z2_20_0);
  ------------------
  |  |   85|     47|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  374|       |
  375|     47|	/* 2^41 - 2^1 */ fe25519_square(&t1,&t0);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  376|       |	/* 2^42 - 2^2 */ fe25519_square(&t0,&t1);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  377|    235|	/* 2^50 - 2^10 */ for (i = 2;i < 10;i += 2) { fe25519_square(&t1,&t0); fe25519_square(&t0,&t1); }
  ------------------
  |  |   86|    188|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
              	/* 2^50 - 2^10 */ for (i = 2;i < 10;i += 2) { fe25519_square(&t1,&t0); fe25519_square(&t0,&t1); }
  ------------------
  |  |   86|    188|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  |  Branch (377:31): [True: 188, False: 47]
  ------------------
  378|       |	/* 2^50 - 2^0 */ fe25519_mul(&z2_50_0,&t0,&z2_10_0);
  ------------------
  |  |   85|     47|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  379|       |
  380|     47|	/* 2^51 - 2^1 */ fe25519_square(&t0,&z2_50_0);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  381|       |	/* 2^52 - 2^2 */ fe25519_square(&t1,&t0);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  382|  1.17k|	/* 2^100 - 2^50 */ for (i = 2;i < 50;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); }
  ------------------
  |  |   86|  1.12k|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
              	/* 2^100 - 2^50 */ for (i = 2;i < 50;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); }
  ------------------
  |  |   86|  1.12k|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  |  Branch (382:32): [True: 1.12k, False: 47]
  ------------------
  383|       |	/* 2^100 - 2^0 */ fe25519_mul(&z2_100_0,&t1,&z2_50_0);
  ------------------
  |  |   85|     47|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  384|       |
  385|     47|	/* 2^101 - 2^1 */ fe25519_square(&t1,&z2_100_0);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  386|       |	/* 2^102 - 2^2 */ fe25519_square(&t0,&t1);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  387|  2.35k|	/* 2^200 - 2^100 */ for (i = 2;i < 100;i += 2) { fe25519_square(&t1,&t0); fe25519_square(&t0,&t1); }
  ------------------
  |  |   86|  2.30k|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
              	/* 2^200 - 2^100 */ for (i = 2;i < 100;i += 2) { fe25519_square(&t1,&t0); fe25519_square(&t0,&t1); }
  ------------------
  |  |   86|  2.30k|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  |  Branch (387:33): [True: 2.30k, False: 47]
  ------------------
  388|       |	/* 2^200 - 2^0 */ fe25519_mul(&t1,&t0,&z2_100_0);
  ------------------
  |  |   85|     47|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  389|       |
  390|     47|	/* 2^201 - 2^1 */ fe25519_square(&t0,&t1);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  391|       |	/* 2^202 - 2^2 */ fe25519_square(&t1,&t0);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  392|  1.17k|	/* 2^250 - 2^50 */ for (i = 2;i < 50;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); }
  ------------------
  |  |   86|  1.12k|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
              	/* 2^250 - 2^50 */ for (i = 2;i < 50;i += 2) { fe25519_square(&t0,&t1); fe25519_square(&t1,&t0); }
  ------------------
  |  |   86|  1.12k|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  |  Branch (392:32): [True: 1.12k, False: 47]
  ------------------
  393|       |	/* 2^250 - 2^0 */ fe25519_mul(&t0,&t1,&z2_50_0);
  ------------------
  |  |   85|     47|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  394|       |
  395|     47|	/* 2^251 - 2^1 */ fe25519_square(&t1,&t0);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  396|       |	/* 2^252 - 2^2 */ fe25519_square(&t0,&t1);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  397|       |	/* 2^253 - 2^3 */ fe25519_square(&t1,&t0);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  398|       |	/* 2^254 - 2^4 */ fe25519_square(&t0,&t1);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  399|       |	/* 2^255 - 2^5 */ fe25519_square(&t1,&t0);
  ------------------
  |  |   86|     47|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
  400|       |	/* 2^255 - 21 */ fe25519_mul(r,&t1,&z11);
  ------------------
  |  |   85|     47|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
  401|     47|}
ed25519.c:crypto_sign_ed25519_ref_fe25519_pack:
  227|     47|{
  228|     47|  int i;
  229|     47|  fe25519 y = *x;
  ------------------
  |  |   72|     47|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
  230|     47|  fe25519_freeze(&y);
  ------------------
  |  |   73|     47|#define fe25519_freeze       crypto_sign_ed25519_ref_fe25519_freeze
  ------------------
  231|  1.55k|  for(i=0;i<32;i++)
  ------------------
  |  Branch (231:11): [True: 1.50k, False: 47]
  ------------------
  232|  1.50k|    r[i] = y.v[i];
  233|     47|}
ed25519.c:crypto_sign_ed25519_ref_sc25519_from64bytes:
  614|     47|{
  615|     47|  int i;
  616|     47|  crypto_uint32 t[64];
  617|  3.05k|  for(i=0;i<64;i++) t[i] = x[i];
  ------------------
  |  Branch (617:11): [True: 3.00k, False: 47]
  ------------------
  618|     47|  barrett_reduce(r, t);
  619|     47|}
ed25519.c:crypto_sign_ed25519_ref_double_scalarmult_vartime:
 1852|     47|{
 1853|     47|  ge25519_p1p1 tp1p1;
 1854|     47|  ge25519_p3 pre[16];
  ------------------
  |  |  771|     47|#define ge25519_p3 ge25519
  |  |  ------------------
  |  |  |  |  724|     47|#define ge25519                           crypto_sign_ed25519_ref_ge25519
  |  |  ------------------
  ------------------
 1855|     47|  unsigned char b[127];
 1856|     47|  int i;
 1857|       |
 1858|       |  /* precomputation                                                        s2 s1 */
 1859|     47|  setneutral(pre);                                                      /* 00 00 */
 1860|     47|  pre[1] = *p1;                                                         /* 00 01 */
 1861|     47|  dbl_p1p1(&tp1p1,(ge25519_p2 *)p1);      p1p1_to_p3( &pre[2], &tp1p1); /* 00 10 */
 1862|     47|  add_p1p1(&tp1p1,&pre[1], &pre[2]);      p1p1_to_p3( &pre[3], &tp1p1); /* 00 11 */
 1863|     47|  pre[4] = *p2;                                                         /* 01 00 */
 1864|     47|  add_p1p1(&tp1p1,&pre[1], &pre[4]);      p1p1_to_p3( &pre[5], &tp1p1); /* 01 01 */
 1865|     47|  add_p1p1(&tp1p1,&pre[2], &pre[4]);      p1p1_to_p3( &pre[6], &tp1p1); /* 01 10 */
 1866|     47|  add_p1p1(&tp1p1,&pre[3], &pre[4]);      p1p1_to_p3( &pre[7], &tp1p1); /* 01 11 */
 1867|     47|  dbl_p1p1(&tp1p1,(ge25519_p2 *)p2);      p1p1_to_p3( &pre[8], &tp1p1); /* 10 00 */
 1868|     47|  add_p1p1(&tp1p1,&pre[1], &pre[8]);      p1p1_to_p3( &pre[9], &tp1p1); /* 10 01 */
 1869|     47|  dbl_p1p1(&tp1p1,(ge25519_p2 *)&pre[5]); p1p1_to_p3(&pre[10], &tp1p1); /* 10 10 */
 1870|     47|  add_p1p1(&tp1p1,&pre[3], &pre[8]);      p1p1_to_p3(&pre[11], &tp1p1); /* 10 11 */
 1871|     47|  add_p1p1(&tp1p1,&pre[4], &pre[8]);      p1p1_to_p3(&pre[12], &tp1p1); /* 11 00 */
 1872|     47|  add_p1p1(&tp1p1,&pre[1],&pre[12]);      p1p1_to_p3(&pre[13], &tp1p1); /* 11 01 */
 1873|     47|  add_p1p1(&tp1p1,&pre[2],&pre[12]);      p1p1_to_p3(&pre[14], &tp1p1); /* 11 10 */
 1874|     47|  add_p1p1(&tp1p1,&pre[3],&pre[12]);      p1p1_to_p3(&pre[15], &tp1p1); /* 11 11 */
 1875|       |
 1876|     47|  sc25519_2interleave2(b,s1,s2);
  ------------------
  |  |  469|     47|#define sc25519_2interleave2     crypto_sign_ed25519_ref_sc25519_2interleave2
  ------------------
 1877|       |
 1878|       |  /* scalar multiplication */
 1879|     47|  *r = pre[b[126]];
 1880|  5.96k|  for(i=125;i>=0;i--)
  ------------------
  |  Branch (1880:13): [True: 5.92k, False: 47]
  ------------------
 1881|  5.92k|  {
 1882|  5.92k|    dbl_p1p1(&tp1p1, (ge25519_p2 *)r);
 1883|  5.92k|    p1p1_to_p2((ge25519_p2 *) r, &tp1p1);
 1884|  5.92k|    dbl_p1p1(&tp1p1, (ge25519_p2 *)r);
 1885|  5.92k|    if(b[i]!=0)
  ------------------
  |  Branch (1885:8): [True: 4.76k, False: 1.15k]
  ------------------
 1886|  4.76k|    {
 1887|  4.76k|      p1p1_to_p3(r, &tp1p1);
 1888|  4.76k|      add_p1p1(&tp1p1, r, &pre[b[i]]);
 1889|  4.76k|    }
 1890|  5.92k|    if(i != 0) p1p1_to_p2((ge25519_p2 *)r, &tp1p1);
  ------------------
  |  Branch (1890:8): [True: 5.87k, False: 47]
  ------------------
 1891|     47|    else p1p1_to_p3(r, &tp1p1);
 1892|  5.92k|  }
 1893|     47|}
ed25519.c:setneutral:
 1773|     47|{
 1774|     47|  fe25519_setzero(&r->x);
  ------------------
  |  |   80|     47|#define fe25519_setzero      crypto_sign_ed25519_ref_fe25519_setzero
  ------------------
 1775|     47|  fe25519_setone(&r->y);
  ------------------
  |  |   79|     47|#define fe25519_setone       crypto_sign_ed25519_ref_fe25519_setone
  ------------------
 1776|     47|  fe25519_setone(&r->z);
  ------------------
  |  |   79|     47|#define fe25519_setone       crypto_sign_ed25519_ref_fe25519_setone
  ------------------
 1777|     47|  fe25519_setzero(&r->t);
  ------------------
  |  |   80|     47|#define fe25519_setzero      crypto_sign_ed25519_ref_fe25519_setzero
  ------------------
 1778|     47|}
ed25519.c:dbl_p1p1:
 1717|  11.9k|{
 1718|  11.9k|  fe25519 a,b,c,d;
  ------------------
  |  |   72|  11.9k|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
 1719|  11.9k|  fe25519_square(&a, &p->x);
  ------------------
  |  |   86|  11.9k|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
 1720|  11.9k|  fe25519_square(&b, &p->y);
  ------------------
  |  |   86|  11.9k|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
 1721|  11.9k|  fe25519_square(&c, &p->z);
  ------------------
  |  |   86|  11.9k|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
 1722|  11.9k|  fe25519_add(&c, &c, &c);
  ------------------
  |  |   83|  11.9k|#define fe25519_add          crypto_sign_ed25519_ref_fe25519_add
  ------------------
 1723|  11.9k|  fe25519_neg(&d, &a);
  ------------------
  |  |   81|  11.9k|#define fe25519_neg          crypto_sign_ed25519_ref_fe25519_neg
  ------------------
 1724|       |
 1725|  11.9k|  fe25519_add(&r->x, &p->x, &p->y);
  ------------------
  |  |   83|  11.9k|#define fe25519_add          crypto_sign_ed25519_ref_fe25519_add
  ------------------
 1726|  11.9k|  fe25519_square(&r->x, &r->x);
  ------------------
  |  |   86|  11.9k|#define fe25519_square       crypto_sign_ed25519_ref_fe25519_square
  ------------------
 1727|  11.9k|  fe25519_sub(&r->x, &r->x, &a);
  ------------------
  |  |   84|  11.9k|#define fe25519_sub          crypto_sign_ed25519_ref_fe25519_sub
  ------------------
 1728|  11.9k|  fe25519_sub(&r->x, &r->x, &b);
  ------------------
  |  |   84|  11.9k|#define fe25519_sub          crypto_sign_ed25519_ref_fe25519_sub
  ------------------
 1729|  11.9k|  fe25519_add(&r->z, &d, &b);
  ------------------
  |  |   83|  11.9k|#define fe25519_add          crypto_sign_ed25519_ref_fe25519_add
  ------------------
 1730|  11.9k|  fe25519_sub(&r->t, &r->z, &c);
  ------------------
  |  |   84|  11.9k|#define fe25519_sub          crypto_sign_ed25519_ref_fe25519_sub
  ------------------
 1731|  11.9k|  fe25519_sub(&r->y, &d, &b);
  ------------------
  |  |   84|  11.9k|#define fe25519_sub          crypto_sign_ed25519_ref_fe25519_sub
  ------------------
 1732|  11.9k|}
ed25519.c:p1p1_to_p3:
 1667|  5.42k|{
 1668|  5.42k|  p1p1_to_p2((ge25519_p2 *)r, p);
 1669|  5.42k|  fe25519_mul(&r->t, &p->x, &p->y);
  ------------------
  |  |   85|  5.42k|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1670|  5.42k|}
ed25519.c:add_p1p1:
 1696|  5.23k|{
 1697|  5.23k|  fe25519 a, b, c, d, t;
  ------------------
  |  |   72|  5.23k|#define fe25519              crypto_sign_ed25519_ref_fe25519
  ------------------
 1698|       |
 1699|  5.23k|  fe25519_sub(&a, &p->y, &p->x); /* A = (Y1-X1)*(Y2-X2) */
  ------------------
  |  |   84|  5.23k|#define fe25519_sub          crypto_sign_ed25519_ref_fe25519_sub
  ------------------
 1700|  5.23k|  fe25519_sub(&t, &q->y, &q->x);
  ------------------
  |  |   84|  5.23k|#define fe25519_sub          crypto_sign_ed25519_ref_fe25519_sub
  ------------------
 1701|  5.23k|  fe25519_mul(&a, &a, &t);
  ------------------
  |  |   85|  5.23k|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1702|  5.23k|  fe25519_add(&b, &p->x, &p->y); /* B = (Y1+X1)*(Y2+X2) */
  ------------------
  |  |   83|  5.23k|#define fe25519_add          crypto_sign_ed25519_ref_fe25519_add
  ------------------
 1703|  5.23k|  fe25519_add(&t, &q->x, &q->y);
  ------------------
  |  |   83|  5.23k|#define fe25519_add          crypto_sign_ed25519_ref_fe25519_add
  ------------------
 1704|  5.23k|  fe25519_mul(&b, &b, &t);
  ------------------
  |  |   85|  5.23k|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1705|  5.23k|  fe25519_mul(&c, &p->t, &q->t); /* C = T1*k*T2 */
  ------------------
  |  |   85|  5.23k|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1706|  5.23k|  fe25519_mul(&c, &c, &ge25519_ec2d);
  ------------------
  |  |   85|  5.23k|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1707|  5.23k|  fe25519_mul(&d, &p->z, &q->z); /* D = Z1*2*Z2 */
  ------------------
  |  |   85|  5.23k|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1708|  5.23k|  fe25519_add(&d, &d, &d);
  ------------------
  |  |   83|  5.23k|#define fe25519_add          crypto_sign_ed25519_ref_fe25519_add
  ------------------
 1709|  5.23k|  fe25519_sub(&r->x, &b, &a); /* E = B-A */
  ------------------
  |  |   84|  5.23k|#define fe25519_sub          crypto_sign_ed25519_ref_fe25519_sub
  ------------------
 1710|  5.23k|  fe25519_sub(&r->t, &d, &c); /* F = D-C */
  ------------------
  |  |   84|  5.23k|#define fe25519_sub          crypto_sign_ed25519_ref_fe25519_sub
  ------------------
 1711|  5.23k|  fe25519_add(&r->z, &d, &c); /* G = D+C */
  ------------------
  |  |   83|  5.23k|#define fe25519_add          crypto_sign_ed25519_ref_fe25519_add
  ------------------
 1712|  5.23k|  fe25519_add(&r->y, &b, &a); /* H = B+A */
  ------------------
  |  |   83|  5.23k|#define fe25519_add          crypto_sign_ed25519_ref_fe25519_add
  ------------------
 1713|  5.23k|}
ed25519.c:crypto_sign_ed25519_ref_sc25519_2interleave2:
  706|     47|{
  707|     47|  int i;
  708|  1.50k|  for(i=0;i<31;i++)
  ------------------
  |  Branch (708:11): [True: 1.45k, False: 47]
  ------------------
  709|  1.45k|  {
  710|  1.45k|    r[4*i]   = ( s1->v[i]       & 3) ^ (( s2->v[i]       & 3) << 2);
  711|  1.45k|    r[4*i+1] = ((s1->v[i] >> 2) & 3) ^ (((s2->v[i] >> 2) & 3) << 2);
  712|  1.45k|    r[4*i+2] = ((s1->v[i] >> 4) & 3) ^ (((s2->v[i] >> 4) & 3) << 2);
  713|  1.45k|    r[4*i+3] = ((s1->v[i] >> 6) & 3) ^ (((s2->v[i] >> 6) & 3) << 2);
  714|  1.45k|  }
  715|     47|  r[124] = ( s1->v[31]       & 3) ^ (( s2->v[31]       & 3) << 2);
  716|     47|  r[125] = ((s1->v[31] >> 2) & 3) ^ (((s2->v[31] >> 2) & 3) << 2);
  717|     47|  r[126] = ((s1->v[31] >> 4) & 3) ^ (((s2->v[31] >> 4) & 3) << 2);
  718|     47|}
ed25519.c:p1p1_to_p2:
 1660|  17.2k|{
 1661|  17.2k|  fe25519_mul(&r->x, &p->x, &p->t);
  ------------------
  |  |   85|  17.2k|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1662|  17.2k|  fe25519_mul(&r->y, &p->y, &p->z);
  ------------------
  |  |   85|  17.2k|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1663|  17.2k|  fe25519_mul(&r->z, &p->z, &p->t);
  ------------------
  |  |   85|  17.2k|#define fe25519_mul          crypto_sign_ed25519_ref_fe25519_mul
  ------------------
 1664|  17.2k|}
ed25519.c:crypto_verify_32:
   30|     47|{
   31|     47|  unsigned int differentbits = 0;
   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
   33|     47|  F(0)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   34|     47|  F(1)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   35|     47|  F(2)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   36|     47|  F(3)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   37|     47|  F(4)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   38|     47|  F(5)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   39|     47|  F(6)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   40|     47|  F(7)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   41|     47|  F(8)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   42|     47|  F(9)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   43|     47|  F(10)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   44|     47|  F(11)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   45|     47|  F(12)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   46|     47|  F(13)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   47|     47|  F(14)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   48|     47|  F(15)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   49|     47|  F(16)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   50|     47|  F(17)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   51|     47|  F(18)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   52|     47|  F(19)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   53|     47|  F(20)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   54|     47|  F(21)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   55|     47|  F(22)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   56|     47|  F(23)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   57|     47|  F(24)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   58|     47|  F(25)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   59|     47|  F(26)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   60|     47|  F(27)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   61|     47|  F(28)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   62|     47|  F(29)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   63|     47|  F(30)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   64|     47|  F(31)
  ------------------
  |  |   32|     47|#define F(i) differentbits |= x[i] ^ y[i];
  ------------------
   65|     47|  return (1 & ((differentbits - 1) >> 8)) - 1;
   66|     47|}

crypto_hash_sha512:
   19|     47|{
   20|       |
   21|     47|	if (!EVP_Digest(in, inlen, out, NULL, EVP_sha512(), NULL))
  ------------------
  |  Branch (21:6): [True: 0, False: 47]
  ------------------
   22|      0|		return -1;
   23|     47|	return 0;
   24|     47|}

sshlog:
  436|     81|{
  437|     81|	va_list args;
  438|       |
  439|     81|	va_start(args, fmt);
  440|     81|	sshlogv(file, func, line, showfunc, level, suffix, fmt, args);
  441|     81|	va_end(args);
  442|     81|}
sshlogv:
  473|     81|{
  474|     81|	char tag[128], fmt2[MSGBUFSIZ + 128];
  475|     81|	int forced = 0;
  476|     81|	const char *cp;
  477|     81|	size_t i;
  478|       |
  479|       |	/* short circuit processing early if we're not going to log anything */
  480|     81|	if (nlog_verbose == 0 && level > log_level)
  ------------------
  |  Branch (480:6): [True: 81, False: 0]
  |  Branch (480:27): [True: 81, False: 0]
  ------------------
  481|     81|		return;
  482|       |
  483|      0|	snprintf(tag, sizeof(tag), "%.48s:%.48s():%d (pid=%ld)",
  484|      0|	    (cp = strrchr(file, '/')) == NULL ? file : cp + 1, func, line,
  ------------------
  |  Branch (484:6): [True: 0, False: 0]
  ------------------
  485|      0|	    (long)getpid());
  486|      0|	for (i = 0; i < nlog_verbose; i++) {
  ------------------
  |  Branch (486:14): [True: 0, False: 0]
  ------------------
  487|      0|		if (match_pattern_list(tag, log_verbose[i], 0) == 1) {
  ------------------
  |  Branch (487:7): [True: 0, False: 0]
  ------------------
  488|      0|			forced = 1;
  489|      0|			break;
  490|      0|		}
  491|      0|	}
  492|       |
  493|      0|	if (forced)
  ------------------
  |  Branch (493:6): [True: 0, False: 0]
  ------------------
  494|      0|		snprintf(fmt2, sizeof(fmt2), "%s: %s", tag, fmt);
  495|      0|	else if (showfunc)
  ------------------
  |  Branch (495:11): [True: 0, False: 0]
  ------------------
  496|      0|		snprintf(fmt2, sizeof(fmt2), "%s: %s", func, fmt);
  497|      0|	else
  498|      0|		strlcpy(fmt2, fmt, sizeof(fmt2));
  499|       |
  500|      0|	do_log(level, forced, suffix, fmt2, args);
  501|      0|}

freezero:
   26|  34.5k|{
   27|  34.5k|	if (ptr == NULL)
  ------------------
  |  Branch (27:6): [True: 10.9k, False: 23.5k]
  ------------------
   28|  10.9k|		return;
   29|  23.5k|	explicit_bzero(ptr, sz);
   30|  23.5k|	free(ptr);
   31|  23.5k|}

recallocarray:
   39|  4.03k|{
   40|  4.03k|	size_t oldsize, newsize;
   41|  4.03k|	void *newptr;
   42|       |
   43|  4.03k|	if (ptr == NULL)
  ------------------
  |  Branch (43:6): [True: 67, False: 3.97k]
  ------------------
   44|     67|		return calloc(newnmemb, size);
   45|       |
   46|  3.97k|	if ((newnmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
  ------------------
  |  |   35|  7.94k|#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
  ------------------
              	if ((newnmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
  ------------------
  |  |   35|  3.97k|#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
  ------------------
  |  Branch (46:7): [True: 0, False: 3.97k]
  |  Branch (46:38): [True: 0, False: 3.97k]
  ------------------
   47|  3.97k|	    newnmemb > 0 && SIZE_MAX / newnmemb < size) {
  ------------------
  |  Branch (47:6): [True: 0, False: 0]
  |  Branch (47:22): [True: 0, False: 0]
  ------------------
   48|      0|		errno = ENOMEM;
   49|      0|		return NULL;
   50|      0|	}
   51|  3.97k|	newsize = newnmemb * size;
   52|       |
   53|  3.97k|	if ((oldnmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
  ------------------
  |  |   35|  7.94k|#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
  ------------------
              	if ((oldnmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
  ------------------
  |  |   35|  3.97k|#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
  ------------------
  |  Branch (53:7): [True: 0, False: 3.97k]
  |  Branch (53:38): [True: 0, False: 3.97k]
  ------------------
   54|  3.97k|	    oldnmemb > 0 && SIZE_MAX / oldnmemb < size) {
  ------------------
  |  Branch (54:6): [True: 0, False: 0]
  |  Branch (54:22): [True: 0, False: 0]
  ------------------
   55|      0|		errno = EINVAL;
   56|      0|		return NULL;
   57|      0|	}
   58|  3.97k|	oldsize = oldnmemb * size;
   59|       |	
   60|       |	/*
   61|       |	 * Don't bother too much if we're shrinking just a bit,
   62|       |	 * we do not shrink for series of small steps, oh well.
   63|       |	 */
   64|  3.97k|	if (newsize <= oldsize) {
  ------------------
  |  Branch (64:6): [True: 51, False: 3.92k]
  ------------------
   65|     51|		size_t d = oldsize - newsize;
   66|       |
   67|     51|		if (d < oldsize / 2 && d < (size_t)getpagesize()) {
  ------------------
  |  Branch (67:7): [True: 0, False: 51]
  |  Branch (67:26): [True: 0, False: 0]
  ------------------
   68|      0|			memset((char *)ptr + newsize, 0, d);
   69|      0|			return ptr;
   70|      0|		}
   71|     51|	}
   72|       |
   73|  3.97k|	newptr = malloc(newsize);
   74|  3.97k|	if (newptr == NULL)
  ------------------
  |  Branch (74:6): [True: 0, False: 3.97k]
  ------------------
   75|      0|		return NULL;
   76|       |
   77|  3.97k|	if (newsize > oldsize) {
  ------------------
  |  Branch (77:6): [True: 3.92k, False: 51]
  ------------------
   78|  3.92k|		memcpy(newptr, ptr, oldsize);
   79|  3.92k|		memset((char *)newptr + oldsize, 0, newsize - oldsize);
   80|  3.92k|	} else
   81|     51|		memcpy(newptr, ptr, newsize);
   82|       |
   83|  3.97k|	explicit_bzero(ptr, oldsize);
   84|  3.97k|	free(ptr);
   85|       |
   86|  3.97k|	return newptr;
   87|  3.97k|}

LLVMFuzzerTestOneInput:
   10|  2.68k|{
   11|  2.68k|	struct sshkey *k = NULL;
   12|  2.68k|	int r = sshkey_from_blob(data, size, &k);
   13|  2.68k|	if (r == 0) sshkey_free(k);
  ------------------
  |  Branch (13:6): [True: 13, False: 2.67k]
  ------------------
   14|  2.68k|	return 0;
   15|  2.68k|}

ssh-dss.c:ssh_dss_alloc:
   63|  1.59k|{
   64|  1.59k|	if ((k->dsa = DSA_new()) == NULL)
  ------------------
  |  Branch (64:6): [True: 0, False: 1.59k]
  ------------------
   65|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
   66|  1.59k|	return 0;
   67|  1.59k|}
ssh-dss.c:ssh_dss_cleanup:
   71|  1.59k|{
   72|  1.59k|	DSA_free(k->dsa);
   73|  1.59k|	k->dsa = NULL;
   74|  1.59k|}
ssh-dss.c:ssh_dss_deserialize_public:
  203|  1.54k|{
  204|  1.54k|	int ret = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|  1.54k|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  205|  1.54k|	BIGNUM *dsa_p = NULL, *dsa_q = NULL, *dsa_g = NULL, *dsa_pub_key = NULL;
  206|       |
  207|  1.54k|	if (sshbuf_get_bignum2(b, &dsa_p) != 0 ||
  ------------------
  |  Branch (207:6): [True: 65, False: 1.47k]
  ------------------
  208|  1.54k|	    sshbuf_get_bignum2(b, &dsa_q) != 0 ||
  ------------------
  |  Branch (208:6): [True: 40, False: 1.43k]
  ------------------
  209|  1.54k|	    sshbuf_get_bignum2(b, &dsa_g) != 0 ||
  ------------------
  |  Branch (209:6): [True: 8, False: 1.42k]
  ------------------
  210|  1.54k|	    sshbuf_get_bignum2(b, &dsa_pub_key) != 0) {
  ------------------
  |  Branch (210:6): [True: 12, False: 1.41k]
  ------------------
  211|    125|		ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|    125|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  212|    125|		goto out;
  213|    125|	}
  214|  1.41k|	if (!DSA_set0_pqg(key->dsa, dsa_p, dsa_q, dsa_g)) {
  ------------------
  |  Branch (214:6): [True: 0, False: 1.41k]
  ------------------
  215|      0|		ret = SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  216|      0|		goto out;
  217|      0|	}
  218|  1.41k|	dsa_p = dsa_q = dsa_g = NULL; /* transferred */
  219|  1.41k|	if (!DSA_set0_key(key->dsa, dsa_pub_key, NULL)) {
  ------------------
  |  Branch (219:6): [True: 0, False: 1.41k]
  ------------------
  220|      0|		ret = SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  221|      0|		goto out;
  222|      0|	}
  223|  1.41k|	dsa_pub_key = NULL; /* transferred */
  224|       |#ifdef DEBUG_PK
  225|       |	DSA_print_fp(stderr, key->dsa, 8);
  226|       |#endif
  227|       |	/* success */
  228|  1.41k|	ret = 0;
  229|  1.54k| out:
  230|  1.54k|	BN_clear_free(dsa_p);
  231|  1.54k|	BN_clear_free(dsa_q);
  232|  1.54k|	BN_clear_free(dsa_g);
  233|  1.54k|	BN_clear_free(dsa_pub_key);
  234|  1.54k|	return ret;
  235|  1.41k|}
ssh-dss.c:ssh_dss_verify:
  333|    117|{
  334|    117|	DSA_SIG *dsig = NULL;
  335|    117|	BIGNUM *sig_r = NULL, *sig_s = NULL;
  336|    117|	u_char digest[SSH_DIGEST_MAX_LENGTH], *sigblob = NULL;
  337|    117|	size_t len, hlen = ssh_digest_bytes(SSH_DIGEST_SHA1);
  ------------------
  |  |   26|    117|#define SSH_DIGEST_SHA1		1
  ------------------
  338|    117|	int ret = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|    117|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  339|    117|	struct sshbuf *b = NULL;
  340|    117|	char *ktype = NULL;
  341|       |
  342|    117|	if (key == NULL || key->dsa == NULL ||
  ------------------
  |  Branch (342:6): [True: 0, False: 117]
  |  Branch (342:21): [True: 0, False: 117]
  ------------------
  343|    117|	    sshkey_type_plain(key->type) != KEY_DSA ||
  ------------------
  |  Branch (343:6): [True: 0, False: 117]
  ------------------
  344|    117|	    sig == NULL || siglen == 0)
  ------------------
  |  Branch (344:6): [True: 0, False: 117]
  |  Branch (344:21): [True: 0, False: 117]
  ------------------
  345|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  346|    117|	if (hlen == 0)
  ------------------
  |  Branch (346:6): [True: 0, False: 117]
  ------------------
  347|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  348|       |
  349|       |	/* fetch signature */
  350|    117|	if ((b = sshbuf_from(sig, siglen)) == NULL)
  ------------------
  |  Branch (350:6): [True: 0, False: 117]
  ------------------
  351|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  352|    117|	if (sshbuf_get_cstring(b, &ktype, NULL) != 0 ||
  ------------------
  |  Branch (352:6): [True: 24, False: 93]
  ------------------
  353|    117|	    sshbuf_get_string(b, &sigblob, &len) != 0) {
  ------------------
  |  Branch (353:6): [True: 3, False: 90]
  ------------------
  354|     27|		ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|     27|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  355|     27|		goto out;
  356|     27|	}
  357|     90|	if (strcmp("ssh-dss", ktype) != 0) {
  ------------------
  |  Branch (357:6): [True: 65, False: 25]
  ------------------
  358|     65|		ret = SSH_ERR_KEY_TYPE_MISMATCH;
  ------------------
  |  |   37|     65|#define SSH_ERR_KEY_TYPE_MISMATCH		-13
  ------------------
  359|     65|		goto out;
  360|     65|	}
  361|     25|	if (sshbuf_len(b) != 0) {
  ------------------
  |  Branch (361:6): [True: 18, False: 7]
  ------------------
  362|     18|		ret = SSH_ERR_UNEXPECTED_TRAILING_DATA;
  ------------------
  |  |   47|     18|#define SSH_ERR_UNEXPECTED_TRAILING_DATA	-23
  ------------------
  363|     18|		goto out;
  364|     18|	}
  365|       |
  366|      7|	if (len != SIGBLOB_LEN) {
  ------------------
  |  |   48|      7|#define SIGBLOB_LEN	(2*INTBLOB_LEN)
  |  |  ------------------
  |  |  |  |   47|      7|#define INTBLOB_LEN	20
  |  |  ------------------
  ------------------
  |  Branch (366:6): [True: 6, False: 1]
  ------------------
  367|      6|		ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      6|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  368|      6|		goto out;
  369|      6|	}
  370|       |
  371|       |	/* parse signature */
  372|      1|	if ((dsig = DSA_SIG_new()) == NULL ||
  ------------------
  |  Branch (372:6): [True: 0, False: 1]
  ------------------
  373|      1|	    (sig_r = BN_new()) == NULL ||
  ------------------
  |  Branch (373:6): [True: 0, False: 1]
  ------------------
  374|      1|	    (sig_s = BN_new()) == NULL) {
  ------------------
  |  Branch (374:6): [True: 0, False: 1]
  ------------------
  375|      0|		ret = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  376|      0|		goto out;
  377|      0|	}
  378|      1|	if ((BN_bin2bn(sigblob, INTBLOB_LEN, sig_r) == NULL) ||
  ------------------
  |  |   47|      1|#define INTBLOB_LEN	20
  ------------------
  |  Branch (378:6): [True: 0, False: 1]
  ------------------
  379|      1|	    (BN_bin2bn(sigblob + INTBLOB_LEN, INTBLOB_LEN, sig_s) == NULL)) {
  ------------------
  |  |   47|      1|#define INTBLOB_LEN	20
  ------------------
              	    (BN_bin2bn(sigblob + INTBLOB_LEN, INTBLOB_LEN, sig_s) == NULL)) {
  ------------------
  |  |   47|      1|#define INTBLOB_LEN	20
  ------------------
  |  Branch (379:6): [True: 0, False: 1]
  ------------------
  380|      0|		ret = SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  381|      0|		goto out;
  382|      0|	}
  383|      1|	if (!DSA_SIG_set0(dsig, sig_r, sig_s)) {
  ------------------
  |  Branch (383:6): [True: 0, False: 1]
  ------------------
  384|      0|		ret = SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  385|      0|		goto out;
  386|      0|	}
  387|      1|	sig_r = sig_s = NULL; /* transferred */
  388|       |
  389|       |	/* sha1 the data */
  390|      1|	if ((ret = ssh_digest_memory(SSH_DIGEST_SHA1, data, dlen,
  ------------------
  |  |   26|      1|#define SSH_DIGEST_SHA1		1
  ------------------
  |  Branch (390:6): [True: 0, False: 1]
  ------------------
  391|      1|	    digest, sizeof(digest))) != 0)
  392|      0|		goto out;
  393|       |
  394|      1|	switch (DSA_do_verify(digest, hlen, dsig, key->dsa)) {
  395|      0|	case 1:
  ------------------
  |  Branch (395:2): [True: 0, False: 1]
  ------------------
  396|      0|		ret = 0;
  397|      0|		break;
  398|      0|	case 0:
  ------------------
  |  Branch (398:2): [True: 0, False: 1]
  ------------------
  399|      0|		ret = SSH_ERR_SIGNATURE_INVALID;
  ------------------
  |  |   45|      0|#define SSH_ERR_SIGNATURE_INVALID		-21
  ------------------
  400|      0|		goto out;
  401|      1|	default:
  ------------------
  |  Branch (401:2): [True: 1, False: 0]
  ------------------
  402|      1|		ret = SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      1|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  403|      1|		goto out;
  404|      1|	}
  405|       |
  406|    117| out:
  407|    117|	explicit_bzero(digest, sizeof(digest));
  408|    117|	DSA_SIG_free(dsig);
  409|    117|	BN_clear_free(sig_r);
  410|    117|	BN_clear_free(sig_s);
  411|    117|	sshbuf_free(b);
  412|    117|	free(ktype);
  413|    117|	if (sigblob != NULL)
  ------------------
  |  Branch (413:6): [True: 90, False: 27]
  ------------------
  414|     90|		freezero(sigblob, len);
  415|    117|	return ret;
  416|      1|}

ssh-ecdsa-sk.c:ssh_ecdsa_sk_cleanup:
   69|      7|{
   70|      7|	sshkey_sk_cleanup(k);
   71|      7|	sshkey_ecdsa_funcs.cleanup(k);
   72|      7|}
ssh-ecdsa-sk.c:ssh_ecdsa_sk_deserialize_public:
  130|      7|{
  131|      7|	int r;
  132|       |
  133|      7|	if ((r = sshkey_ecdsa_funcs.deserialize_public(ktype, b, key)) != 0)
  ------------------
  |  Branch (133:6): [True: 7, False: 0]
  ------------------
  134|      7|		return r;
  135|      0|	if ((r = sshkey_deserialize_sk(b, key)) != 0)
  ------------------
  |  Branch (135:6): [True: 0, False: 0]
  ------------------
  136|      0|		return r;
  137|      0|	return 0;
  138|      0|}

ssh-ecdsa.c:ssh_ecdsa_cleanup:
   67|    276|{
   68|    276|	EC_KEY_free(k->ecdsa);
   69|    276|	k->ecdsa = NULL;
   70|    276|}
ssh-ecdsa.c:ssh_ecdsa_deserialize_public:
  159|    276|{
  160|    276|	int r;
  161|    276|	char *curve = NULL;
  162|       |
  163|    276|	if ((key->ecdsa_nid = sshkey_ecdsa_nid_from_name(ktype)) == -1)
  ------------------
  |  Branch (163:6): [True: 10, False: 266]
  ------------------
  164|     10|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|     10|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  165|    266|	if ((r = sshbuf_get_cstring(b, &curve, NULL)) != 0)
  ------------------
  |  Branch (165:6): [True: 10, False: 256]
  ------------------
  166|     10|		goto out;
  167|    256|	if (key->ecdsa_nid != sshkey_curve_name_to_nid(curve)) {
  ------------------
  |  Branch (167:6): [True: 118, False: 138]
  ------------------
  168|    118|		r = SSH_ERR_EC_CURVE_MISMATCH;
  ------------------
  |  |   39|    118|#define SSH_ERR_EC_CURVE_MISMATCH		-15
  ------------------
  169|    118|		goto out;
  170|    118|	}
  171|    138|	EC_KEY_free(key->ecdsa);
  172|    138|	key->ecdsa = NULL;
  173|    138|	if ((key->ecdsa = EC_KEY_new_by_curve_name(key->ecdsa_nid)) == NULL) {
  ------------------
  |  Branch (173:6): [True: 0, False: 138]
  ------------------
  174|      0|		r = SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  175|      0|		goto out;
  176|      0|	}
  177|    138|	if ((r = sshbuf_get_eckey(b, key->ecdsa)) != 0)
  ------------------
  |  Branch (177:6): [True: 138, False: 0]
  ------------------
  178|    138|		goto out;
  179|      0|	if (sshkey_ec_validate_public(EC_KEY_get0_group(key->ecdsa),
  ------------------
  |  Branch (179:6): [True: 0, False: 0]
  ------------------
  180|      0|	    EC_KEY_get0_public_key(key->ecdsa)) != 0) {
  181|      0|		r = SSH_ERR_KEY_INVALID_EC_VALUE;
  ------------------
  |  |   44|      0|#define SSH_ERR_KEY_INVALID_EC_VALUE		-20
  ------------------
  182|      0|		goto out;
  183|      0|	}
  184|       |	/* success */
  185|      0|	r = 0;
  186|       |#ifdef DEBUG_PK
  187|       |	sshkey_dump_ec_point(EC_KEY_get0_group(key->ecdsa),
  188|       |	    EC_KEY_get0_public_key(key->ecdsa));
  189|       |#endif
  190|    266| out:
  191|    266|	free(curve);
  192|    266|	if (r != 0) {
  ------------------
  |  Branch (192:6): [True: 266, False: 0]
  ------------------
  193|    266|		EC_KEY_free(key->ecdsa);
  194|    266|		key->ecdsa = NULL;
  195|    266|	}
  196|    266|	return r;
  197|      0|}

ssh-ed25519-sk.c:ssh_ed25519_sk_cleanup:
   43|    307|{
   44|    307|	sshkey_sk_cleanup(k);
   45|    307|	sshkey_ed25519_funcs.cleanup(k);
   46|    307|}
ssh-ed25519-sk.c:ssh_ed25519_sk_deserialize_public:
  101|    306|{
  102|    306|	int r;
  103|       |
  104|    306|	if ((r = sshkey_ed25519_funcs.deserialize_public(ktype, b, key)) != 0)
  ------------------
  |  Branch (104:6): [True: 19, False: 287]
  ------------------
  105|     19|		return r;
  106|    287|	if ((r = sshkey_deserialize_sk(b, key)) != 0)
  ------------------
  |  Branch (106:6): [True: 3, False: 284]
  ------------------
  107|      3|		return r;
  108|    284|	return 0;
  109|    287|}
ssh-ed25519-sk.c:ssh_ed25519_sk_verify:
  129|    215|{
  130|    215|	struct sshbuf *b = NULL;
  131|    215|	struct sshbuf *encoded = NULL;
  132|    215|	char *ktype = NULL;
  133|    215|	const u_char *sigblob;
  134|    215|	const u_char *sm;
  135|    215|	u_char *m = NULL;
  136|    215|	u_char apphash[32];
  137|    215|	u_char msghash[32];
  138|    215|	u_char sig_flags;
  139|    215|	u_int sig_counter;
  140|    215|	size_t len;
  141|    215|	unsigned long long smlen = 0, mlen = 0;
  142|    215|	int r = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|    215|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  143|    215|	int ret;
  144|    215|	struct sshkey_sig_details *details = NULL;
  145|       |
  146|    215|	if (detailsp != NULL)
  ------------------
  |  Branch (146:6): [True: 0, False: 215]
  ------------------
  147|      0|		*detailsp = NULL;
  148|       |
  149|    215|	if (key == NULL ||
  ------------------
  |  Branch (149:6): [True: 0, False: 215]
  ------------------
  150|    215|	    sshkey_type_plain(key->type) != KEY_ED25519_SK ||
  ------------------
  |  Branch (150:6): [True: 0, False: 215]
  ------------------
  151|    215|	    key->ed25519_pk == NULL ||
  ------------------
  |  Branch (151:6): [True: 0, False: 215]
  ------------------
  152|    215|	    sig == NULL || siglen == 0)
  ------------------
  |  Branch (152:6): [True: 0, False: 215]
  |  Branch (152:21): [True: 0, False: 215]
  ------------------
  153|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  154|       |
  155|    215|	if ((b = sshbuf_from(sig, siglen)) == NULL)
  ------------------
  |  Branch (155:6): [True: 0, False: 215]
  ------------------
  156|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  157|    215|	if (sshbuf_get_cstring(b, &ktype, NULL) != 0 ||
  ------------------
  |  Branch (157:6): [True: 17, False: 198]
  ------------------
  158|    215|	    sshbuf_get_string_direct(b, &sigblob, &len) != 0 ||
  ------------------
  |  Branch (158:6): [True: 5, False: 193]
  ------------------
  159|    215|	    sshbuf_get_u8(b, &sig_flags) != 0 ||
  ------------------
  |  Branch (159:6): [True: 2, False: 191]
  ------------------
  160|    215|	    sshbuf_get_u32(b, &sig_counter) != 0) {
  ------------------
  |  Branch (160:6): [True: 1, False: 190]
  ------------------
  161|     25|		r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|     25|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  162|     25|		goto out;
  163|     25|	}
  164|       |#ifdef DEBUG_SK
  165|       |	fprintf(stderr, "%s: data:\n", __func__);
  166|       |	/* sshbuf_dump_data(data, datalen, stderr); */
  167|       |	fprintf(stderr, "%s: sigblob:\n", __func__);
  168|       |	sshbuf_dump_data(sigblob, len, stderr);
  169|       |	fprintf(stderr, "%s: sig_flags = 0x%02x, sig_counter = %u\n",
  170|       |	    __func__, sig_flags, sig_counter);
  171|       |#endif
  172|    190|	if (strcmp(sshkey_ssh_name_plain(key), ktype) != 0) {
  ------------------
  |  Branch (172:6): [True: 154, False: 36]
  ------------------
  173|    154|		r = SSH_ERR_KEY_TYPE_MISMATCH;
  ------------------
  |  |   37|    154|#define SSH_ERR_KEY_TYPE_MISMATCH		-13
  ------------------
  174|    154|		goto out;
  175|    154|	}
  176|     36|	if (sshbuf_len(b) != 0) {
  ------------------
  |  Branch (176:6): [True: 18, False: 18]
  ------------------
  177|     18|		r = SSH_ERR_UNEXPECTED_TRAILING_DATA;
  ------------------
  |  |   47|     18|#define SSH_ERR_UNEXPECTED_TRAILING_DATA	-23
  ------------------
  178|     18|		goto out;
  179|     18|	}
  180|     18|	if (len > crypto_sign_ed25519_BYTES) {
  ------------------
  |  |   37|     18|#define crypto_sign_ed25519_BYTES 64U
  ------------------
  |  Branch (180:6): [True: 1, False: 17]
  ------------------
  181|      1|		r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      1|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  182|      1|		goto out;
  183|      1|	}
  184|     17|	if (ssh_digest_memory(SSH_DIGEST_SHA256, key->sk_application,
  ------------------
  |  |   27|     17|#define SSH_DIGEST_SHA256	2
  ------------------
  |  Branch (184:6): [True: 0, False: 17]
  ------------------
  185|     17|	    strlen(key->sk_application), apphash, sizeof(apphash)) != 0 ||
  186|     17|	    ssh_digest_memory(SSH_DIGEST_SHA256, data, dlen,
  ------------------
  |  |   27|     17|#define SSH_DIGEST_SHA256	2
  ------------------
  |  Branch (186:6): [True: 0, False: 17]
  ------------------
  187|     17|	    msghash, sizeof(msghash)) != 0) {
  188|      0|		r = SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  189|      0|		goto out;
  190|      0|	}
  191|       |#ifdef DEBUG_SK
  192|       |	fprintf(stderr, "%s: hashed application:\n", __func__);
  193|       |	sshbuf_dump_data(apphash, sizeof(apphash), stderr);
  194|       |	fprintf(stderr, "%s: hashed message:\n", __func__);
  195|       |	sshbuf_dump_data(msghash, sizeof(msghash), stderr);
  196|       |#endif
  197|     17|	if ((details = calloc(1, sizeof(*details))) == NULL) {
  ------------------
  |  Branch (197:6): [True: 0, False: 17]
  ------------------
  198|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  199|      0|		goto out;
  200|      0|	}
  201|     17|	details->sk_counter = sig_counter;
  202|     17|	details->sk_flags = sig_flags;
  203|     17|	if ((encoded = sshbuf_new()) == NULL) {
  ------------------
  |  |   36|     17|#define sshbuf_new() sshbuf_new_label(__func__)
  ------------------
  |  Branch (203:6): [True: 0, False: 17]
  ------------------
  204|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  205|      0|		goto out;
  206|      0|	}
  207|     17|	if (sshbuf_put(encoded, sigblob, len) != 0 ||
  ------------------
  |  Branch (207:6): [True: 0, False: 17]
  ------------------
  208|     17|	    sshbuf_put(encoded, apphash, sizeof(apphash)) != 0 ||
  ------------------
  |  Branch (208:6): [True: 0, False: 17]
  ------------------
  209|     17|	    sshbuf_put_u8(encoded, sig_flags) != 0 ||
  ------------------
  |  Branch (209:6): [True: 0, False: 17]
  ------------------
  210|     17|	    sshbuf_put_u32(encoded, sig_counter) != 0 ||
  ------------------
  |  Branch (210:6): [True: 0, False: 17]
  ------------------
  211|     17|	    sshbuf_put(encoded, msghash, sizeof(msghash)) != 0) {
  ------------------
  |  Branch (211:6): [True: 0, False: 17]
  ------------------
  212|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  213|      0|		goto out;
  214|      0|	}
  215|       |#ifdef DEBUG_SK
  216|       |	fprintf(stderr, "%s: signed buf:\n", __func__);
  217|       |	sshbuf_dump(encoded, stderr);
  218|       |#endif
  219|     17|	sm = sshbuf_ptr(encoded);
  220|     17|	smlen = sshbuf_len(encoded);
  221|     17|	mlen = smlen;
  222|     17|	if ((m = malloc(smlen)) == NULL) {
  ------------------
  |  Branch (222:6): [True: 0, False: 17]
  ------------------
  223|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  224|      0|		goto out;
  225|      0|	}
  226|     17|	if ((ret = crypto_sign_ed25519_open(m, &mlen, sm, smlen,
  ------------------
  |  Branch (226:6): [True: 16, False: 1]
  ------------------
  227|     17|	    key->ed25519_pk)) != 0) {
  228|     16|		debug2_f("crypto_sign_ed25519_open failed: %d", ret);
  ------------------
  |  |  101|     16|#define debug2_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  229|     16|	}
  230|     17|	if (ret != 0 || mlen != smlen - len) {
  ------------------
  |  Branch (230:6): [True: 16, False: 1]
  |  Branch (230:18): [True: 0, False: 1]
  ------------------
  231|     16|		r = SSH_ERR_SIGNATURE_INVALID;
  ------------------
  |  |   45|     16|#define SSH_ERR_SIGNATURE_INVALID		-21
  ------------------
  232|     16|		goto out;
  233|     16|	}
  234|       |	/* XXX compare 'm' and 'sm + len' ? */
  235|       |	/* success */
  236|      1|	r = 0;
  237|      1|	if (detailsp != NULL) {
  ------------------
  |  Branch (237:6): [True: 0, False: 1]
  ------------------
  238|      0|		*detailsp = details;
  239|      0|		details = NULL;
  240|      0|	}
  241|    215| out:
  242|    215|	if (m != NULL)
  ------------------
  |  Branch (242:6): [True: 17, False: 198]
  ------------------
  243|     17|		freezero(m, smlen); /* NB mlen may be invalid if r != 0 */
  244|    215|	sshkey_sig_details_free(details);
  245|    215|	sshbuf_free(b);
  246|    215|	sshbuf_free(encoded);
  247|    215|	free(ktype);
  248|    215|	return r;
  249|      1|}

ssh-ed25519.c:ssh_ed25519_cleanup:
   37|    708|{
   38|    708|	freezero(k->ed25519_pk, ED25519_PK_SZ);
  ------------------
  |  |  159|    708|#define	ED25519_PK_SZ	crypto_sign_ed25519_PUBLICKEYBYTES
  |  |  ------------------
  |  |  |  |   36|    708|#define crypto_sign_ed25519_PUBLICKEYBYTES 32U
  |  |  ------------------
  ------------------
   39|    708|	freezero(k->ed25519_sk, ED25519_SK_SZ);
  ------------------
  |  |  158|    708|#define	ED25519_SK_SZ	crypto_sign_ed25519_SECRETKEYBYTES
  |  |  ------------------
  |  |  |  |   35|    708|#define crypto_sign_ed25519_SECRETKEYBYTES 64U
  |  |  ------------------
  ------------------
   40|    708|	k->ed25519_pk = NULL;
   41|    708|	k->ed25519_sk = NULL;
   42|    708|}
ssh-ed25519.c:ssh_ed25519_deserialize_public:
  105|    706|{
  106|    706|	u_char *pk = NULL;
  107|    706|	size_t len = 0;
  108|    706|	int r;
  109|       |
  110|    706|	if ((r = sshbuf_get_string(b, &pk, &len)) != 0)
  ------------------
  |  Branch (110:6): [True: 65, False: 641]
  ------------------
  111|     65|		return r;
  112|    641|	if (len != ED25519_PK_SZ) {
  ------------------
  |  |  159|    641|#define	ED25519_PK_SZ	crypto_sign_ed25519_PUBLICKEYBYTES
  |  |  ------------------
  |  |  |  |   36|    641|#define crypto_sign_ed25519_PUBLICKEYBYTES 32U
  |  |  ------------------
  ------------------
  |  Branch (112:6): [True: 55, False: 586]
  ------------------
  113|     55|		freezero(pk, len);
  114|     55|		return SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|     55|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  115|     55|	}
  116|    586|	key->ed25519_pk = pk;
  117|    586|	return 0;
  118|    641|}
ssh-ed25519.c:ssh_ed25519_verify:
  209|    205|{
  210|    205|	struct sshbuf *b = NULL;
  211|    205|	char *ktype = NULL;
  212|    205|	const u_char *sigblob;
  213|    205|	u_char *sm = NULL, *m = NULL;
  214|    205|	size_t len;
  215|    205|	unsigned long long smlen = 0, mlen = 0;
  216|    205|	int r, ret;
  217|       |
  218|    205|	if (key == NULL ||
  ------------------
  |  Branch (218:6): [True: 0, False: 205]
  ------------------
  219|    205|	    sshkey_type_plain(key->type) != KEY_ED25519 ||
  ------------------
  |  Branch (219:6): [True: 0, False: 205]
  ------------------
  220|    205|	    key->ed25519_pk == NULL ||
  ------------------
  |  Branch (220:6): [True: 0, False: 205]
  ------------------
  221|    205|	    dlen >= INT_MAX - crypto_sign_ed25519_BYTES ||
  ------------------
  |  |   37|    410|#define crypto_sign_ed25519_BYTES 64U
  ------------------
  |  Branch (221:6): [True: 0, False: 205]
  ------------------
  222|    205|	    sig == NULL || siglen == 0)
  ------------------
  |  Branch (222:6): [True: 0, False: 205]
  |  Branch (222:21): [True: 0, False: 205]
  ------------------
  223|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  224|       |
  225|    205|	if ((b = sshbuf_from(sig, siglen)) == NULL)
  ------------------
  |  Branch (225:6): [True: 0, False: 205]
  ------------------
  226|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  227|    205|	if ((r = sshbuf_get_cstring(b, &ktype, NULL)) != 0 ||
  ------------------
  |  Branch (227:6): [True: 30, False: 175]
  ------------------
  228|    205|	    (r = sshbuf_get_string_direct(b, &sigblob, &len)) != 0)
  ------------------
  |  Branch (228:6): [True: 5, False: 170]
  ------------------
  229|     35|		goto out;
  230|    170|	if (strcmp("ssh-ed25519", ktype) != 0) {
  ------------------
  |  Branch (230:6): [True: 101, False: 69]
  ------------------
  231|    101|		r = SSH_ERR_KEY_TYPE_MISMATCH;
  ------------------
  |  |   37|    101|#define SSH_ERR_KEY_TYPE_MISMATCH		-13
  ------------------
  232|    101|		goto out;
  233|    101|	}
  234|     69|	if (sshbuf_len(b) != 0) {
  ------------------
  |  Branch (234:6): [True: 2, False: 67]
  ------------------
  235|      2|		r = SSH_ERR_UNEXPECTED_TRAILING_DATA;
  ------------------
  |  |   47|      2|#define SSH_ERR_UNEXPECTED_TRAILING_DATA	-23
  ------------------
  236|      2|		goto out;
  237|      2|	}
  238|     67|	if (len > crypto_sign_ed25519_BYTES) {
  ------------------
  |  |   37|     67|#define crypto_sign_ed25519_BYTES 64U
  ------------------
  |  Branch (238:6): [True: 2, False: 65]
  ------------------
  239|      2|		r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      2|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  240|      2|		goto out;
  241|      2|	}
  242|     65|	if (dlen >= SIZE_MAX - len) {
  ------------------
  |  Branch (242:6): [True: 0, False: 65]
  ------------------
  243|      0|		r = SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  244|      0|		goto out;
  245|      0|	}
  246|     65|	smlen = len + dlen;
  247|     65|	mlen = smlen;
  248|     65|	if ((sm = malloc(smlen)) == NULL || (m = malloc(mlen)) == NULL) {
  ------------------
  |  Branch (248:6): [True: 0, False: 65]
  |  Branch (248:38): [True: 0, False: 65]
  ------------------
  249|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  250|      0|		goto out;
  251|      0|	}
  252|     65|	memcpy(sm, sigblob, len);
  253|     65|	memcpy(sm+len, data, dlen);
  254|     65|	if ((ret = crypto_sign_ed25519_open(m, &mlen, sm, smlen,
  ------------------
  |  Branch (254:6): [True: 65, False: 0]
  ------------------
  255|     65|	    key->ed25519_pk)) != 0) {
  256|     65|		debug2_f("crypto_sign_ed25519_open failed: %d", ret);
  ------------------
  |  |  101|     65|#define debug2_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  257|     65|	}
  258|     65|	if (ret != 0 || mlen != dlen) {
  ------------------
  |  Branch (258:6): [True: 65, False: 0]
  |  Branch (258:18): [True: 0, False: 0]
  ------------------
  259|     65|		r = SSH_ERR_SIGNATURE_INVALID;
  ------------------
  |  |   45|     65|#define SSH_ERR_SIGNATURE_INVALID		-21
  ------------------
  260|     65|		goto out;
  261|     65|	}
  262|       |	/* XXX compare 'm' and 'data' ? */
  263|       |	/* success */
  264|      0|	r = 0;
  265|    205| out:
  266|    205|	if (sm != NULL)
  ------------------
  |  Branch (266:6): [True: 65, False: 140]
  ------------------
  267|     65|		freezero(sm, smlen);
  268|    205|	if (m != NULL)
  ------------------
  |  Branch (268:6): [True: 65, False: 140]
  ------------------
  269|     65|		freezero(m, smlen); /* NB mlen may be invalid if r != 0 */
  270|    205|	sshbuf_free(b);
  271|    205|	free(ktype);
  272|    205|	return r;
  273|      0|}

ssh-rsa.c:ssh_rsa_alloc:
   54|    392|{
   55|    392|	if ((k->rsa = RSA_new()) == NULL)
  ------------------
  |  Branch (55:6): [True: 0, False: 392]
  ------------------
   56|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
   57|    392|	return 0;
   58|    392|}
ssh-rsa.c:ssh_rsa_cleanup:
   62|    392|{
   63|    392|	RSA_free(k->rsa);
   64|    392|	k->rsa = NULL;
   65|    392|}
ssh-rsa.c:ssh_rsa_deserialize_public:
  188|    391|{
  189|    391|	int ret = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|    391|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  190|    391|	BIGNUM *rsa_n = NULL, *rsa_e = NULL;
  191|       |
  192|    391|	if (sshbuf_get_bignum2(b, &rsa_e) != 0 ||
  ------------------
  |  Branch (192:6): [True: 39, False: 352]
  ------------------
  193|    391|	    sshbuf_get_bignum2(b, &rsa_n) != 0) {
  ------------------
  |  Branch (193:6): [True: 30, False: 322]
  ------------------
  194|     69|		ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|     69|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  195|     69|		goto out;
  196|     69|	}
  197|    322|	if (!RSA_set0_key(key->rsa, rsa_n, rsa_e, NULL)) {
  ------------------
  |  Branch (197:6): [True: 0, False: 322]
  ------------------
  198|      0|		ret = SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|      0|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  199|      0|		goto out;
  200|      0|	}
  201|    322|	rsa_n = rsa_e = NULL; /* transferred */
  202|    322|	if ((ret = sshkey_check_rsa_length(key, 0)) != 0)
  ------------------
  |  Branch (202:6): [True: 27, False: 295]
  ------------------
  203|     27|		goto out;
  204|       |#ifdef DEBUG_PK
  205|       |	RSA_print_fp(stderr, key->rsa, 8);
  206|       |#endif
  207|       |	/* success */
  208|    295|	ret = 0;
  209|    391| out:
  210|    391|	BN_clear_free(rsa_n);
  211|    391|	BN_clear_free(rsa_e);
  212|    391|	return ret;
  213|    295|}
ssh-rsa.c:rsa_hash_id_from_ident:
  289|    235|{
  290|    235|	if (strcmp(ident, "ssh-rsa") == 0)
  ------------------
  |  Branch (290:6): [True: 25, False: 210]
  ------------------
  291|     25|		return SSH_DIGEST_SHA1;
  ------------------
  |  |   26|     25|#define SSH_DIGEST_SHA1		1
  ------------------
  292|    210|	if (strcmp(ident, "rsa-sha2-256") == 0)
  ------------------
  |  Branch (292:6): [True: 9, False: 201]
  ------------------
  293|      9|		return SSH_DIGEST_SHA256;
  ------------------
  |  |   27|      9|#define SSH_DIGEST_SHA256	2
  ------------------
  294|    201|	if (strcmp(ident, "rsa-sha2-512") == 0)
  ------------------
  |  Branch (294:6): [True: 12, False: 189]
  ------------------
  295|     12|		return SSH_DIGEST_SHA512;
  ------------------
  |  |   29|     12|#define SSH_DIGEST_SHA512	4
  ------------------
  296|    189|	return -1;
  297|    201|}
ssh-rsa.c:ssh_rsa_verify:
  478|    274|{
  479|    274|	const BIGNUM *rsa_n;
  480|    274|	char *sigtype = NULL;
  481|    274|	int hash_alg, want_alg, ret = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|    274|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  482|    274|	size_t len = 0, diff, modlen, hlen;
  483|    274|	struct sshbuf *b = NULL;
  484|    274|	u_char digest[SSH_DIGEST_MAX_LENGTH], *osigblob, *sigblob = NULL;
  485|       |
  486|    274|	if (key == NULL || key->rsa == NULL ||
  ------------------
  |  Branch (486:6): [True: 0, False: 274]
  |  Branch (486:21): [True: 0, False: 274]
  ------------------
  487|    274|	    sshkey_type_plain(key->type) != KEY_RSA ||
  ------------------
  |  Branch (487:6): [True: 0, False: 274]
  ------------------
  488|    274|	    sig == NULL || siglen == 0)
  ------------------
  |  Branch (488:6): [True: 0, False: 274]
  |  Branch (488:21): [True: 0, False: 274]
  ------------------
  489|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  490|    274|	RSA_get0_key(key->rsa, &rsa_n, NULL, NULL);
  491|    274|	if (BN_num_bits(rsa_n) < SSH_RSA_MINIMUM_MODULUS_SIZE)
  ------------------
  |  |   53|    274|#define SSH_RSA_MINIMUM_MODULUS_SIZE	1024
  ------------------
  |  Branch (491:6): [True: 0, False: 274]
  ------------------
  492|      0|		return SSH_ERR_KEY_LENGTH;
  ------------------
  |  |   80|      0|#define SSH_ERR_KEY_LENGTH			-56
  ------------------
  493|       |
  494|    274|	if ((b = sshbuf_from(sig, siglen)) == NULL)
  ------------------
  |  Branch (494:6): [True: 0, False: 274]
  ------------------
  495|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  496|    274|	if (sshbuf_get_cstring(b, &sigtype, NULL) != 0) {
  ------------------
  |  Branch (496:6): [True: 39, False: 235]
  ------------------
  497|     39|		ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|     39|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  498|     39|		goto out;
  499|     39|	}
  500|    235|	if ((hash_alg = rsa_hash_id_from_ident(sigtype)) == -1) {
  ------------------
  |  Branch (500:6): [True: 189, False: 46]
  ------------------
  501|    189|		ret = SSH_ERR_KEY_TYPE_MISMATCH;
  ------------------
  |  |   37|    189|#define SSH_ERR_KEY_TYPE_MISMATCH		-13
  ------------------
  502|    189|		goto out;
  503|    189|	}
  504|       |	/*
  505|       |	 * Allow ssh-rsa-cert-v01 certs to generate SHA2 signatures for
  506|       |	 * legacy reasons, but otherwise the signature type should match.
  507|       |	 */
  508|     46|	if (alg != NULL && strcmp(alg, "ssh-rsa-cert-v01@openssh.com") != 0) {
  ------------------
  |  Branch (508:6): [True: 0, False: 46]
  |  Branch (508:21): [True: 0, False: 0]
  ------------------
  509|      0|		if ((want_alg = rsa_hash_id_from_keyname(alg)) == -1) {
  ------------------
  |  Branch (509:7): [True: 0, False: 0]
  ------------------
  510|      0|			ret = SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  511|      0|			goto out;
  512|      0|		}
  513|      0|		if (hash_alg != want_alg) {
  ------------------
  |  Branch (513:7): [True: 0, False: 0]
  ------------------
  514|      0|			ret = SSH_ERR_SIGNATURE_INVALID;
  ------------------
  |  |   45|      0|#define SSH_ERR_SIGNATURE_INVALID		-21
  ------------------
  515|      0|			goto out;
  516|      0|		}
  517|      0|	}
  518|     46|	if (sshbuf_get_string(b, &sigblob, &len) != 0) {
  ------------------
  |  Branch (518:6): [True: 4, False: 42]
  ------------------
  519|      4|		ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      4|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  520|      4|		goto out;
  521|      4|	}
  522|     42|	if (sshbuf_len(b) != 0) {
  ------------------
  |  Branch (522:6): [True: 17, False: 25]
  ------------------
  523|     17|		ret = SSH_ERR_UNEXPECTED_TRAILING_DATA;
  ------------------
  |  |   47|     17|#define SSH_ERR_UNEXPECTED_TRAILING_DATA	-23
  ------------------
  524|     17|		goto out;
  525|     17|	}
  526|       |	/* RSA_verify expects a signature of RSA_size */
  527|     25|	modlen = RSA_size(key->rsa);
  528|     25|	if (len > modlen) {
  ------------------
  |  Branch (528:6): [True: 9, False: 16]
  ------------------
  529|      9|		ret = SSH_ERR_KEY_BITS_MISMATCH;
  ------------------
  |  |   35|      9|#define SSH_ERR_KEY_BITS_MISMATCH		-11
  ------------------
  530|      9|		goto out;
  531|     16|	} else if (len < modlen) {
  ------------------
  |  Branch (531:13): [True: 15, False: 1]
  ------------------
  532|     15|		diff = modlen - len;
  533|     15|		osigblob = sigblob;
  534|     15|		if ((sigblob = realloc(sigblob, modlen)) == NULL) {
  ------------------
  |  Branch (534:7): [True: 0, False: 15]
  ------------------
  535|      0|			sigblob = osigblob; /* put it back for clear/free */
  536|      0|			ret = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  537|      0|			goto out;
  538|      0|		}
  539|     15|		memmove(sigblob + diff, sigblob, len);
  540|     15|		explicit_bzero(sigblob, diff);
  541|     15|		len = modlen;
  542|     15|	}
  543|     16|	if ((hlen = ssh_digest_bytes(hash_alg)) == 0) {
  ------------------
  |  Branch (543:6): [True: 0, False: 16]
  ------------------
  544|      0|		ret = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  545|      0|		goto out;
  546|      0|	}
  547|     16|	if ((ret = ssh_digest_memory(hash_alg, data, dlen,
  ------------------
  |  Branch (547:6): [True: 0, False: 16]
  ------------------
  548|     16|	    digest, sizeof(digest))) != 0)
  549|      0|		goto out;
  550|       |
  551|     16|	ret = openssh_RSA_verify(hash_alg, digest, hlen, sigblob, len,
  552|     16|	    key->rsa);
  553|    274| out:
  554|    274|	freezero(sigblob, len);
  555|    274|	free(sigtype);
  556|    274|	sshbuf_free(b);
  557|    274|	explicit_bzero(digest, sizeof(digest));
  558|    274|	return ret;
  559|     16|}
ssh-rsa.c:openssh_RSA_verify:
  635|     16|{
  636|     16|	size_t rsasize = 0, oidlen = 0, hlen = 0;
  637|     16|	int ret, len, oidmatch, hashmatch;
  638|     16|	const u_char *oid = NULL;
  639|     16|	u_char *decrypted = NULL;
  640|       |
  641|     16|	if ((ret = rsa_hash_alg_oid(hash_alg, &oid, &oidlen)) != 0)
  ------------------
  |  Branch (641:6): [True: 0, False: 16]
  ------------------
  642|      0|		return ret;
  643|     16|	ret = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|     16|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  644|     16|	hlen = ssh_digest_bytes(hash_alg);
  645|     16|	if (hashlen != hlen) {
  ------------------
  |  Branch (645:6): [True: 0, False: 16]
  ------------------
  646|      0|		ret = SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  647|      0|		goto done;
  648|      0|	}
  649|     16|	rsasize = RSA_size(rsa);
  650|     16|	if (rsasize <= 0 || rsasize > SSHBUF_MAX_BIGNUM ||
  ------------------
  |  |   33|     32|#define SSHBUF_MAX_BIGNUM	(16384 / 8)	/* Max bignum *bytes* */
  ------------------
  |  Branch (650:6): [True: 0, False: 16]
  |  Branch (650:22): [True: 0, False: 16]
  ------------------
  651|     16|	    siglen == 0 || siglen > rsasize) {
  ------------------
  |  Branch (651:6): [True: 0, False: 16]
  |  Branch (651:21): [True: 0, False: 16]
  ------------------
  652|      0|		ret = SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  653|      0|		goto done;
  654|      0|	}
  655|     16|	if ((decrypted = malloc(rsasize)) == NULL) {
  ------------------
  |  Branch (655:6): [True: 0, False: 16]
  ------------------
  656|      0|		ret = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  657|      0|		goto done;
  658|      0|	}
  659|     16|	if ((len = RSA_public_decrypt(siglen, sigbuf, decrypted, rsa,
  ------------------
  |  Branch (659:6): [True: 16, False: 0]
  ------------------
  660|     16|	    RSA_PKCS1_PADDING)) < 0) {
  661|     16|		ret = SSH_ERR_LIBCRYPTO_ERROR;
  ------------------
  |  |   46|     16|#define SSH_ERR_LIBCRYPTO_ERROR			-22
  ------------------
  662|     16|		goto done;
  663|     16|	}
  664|      0|	if (len < 0 || (size_t)len != hlen + oidlen) {
  ------------------
  |  Branch (664:6): [True: 0, False: 0]
  |  Branch (664:17): [True: 0, False: 0]
  ------------------
  665|      0|		ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  666|      0|		goto done;
  667|      0|	}
  668|      0|	oidmatch = timingsafe_bcmp(decrypted, oid, oidlen) == 0;
  669|      0|	hashmatch = timingsafe_bcmp(decrypted + oidlen, hash, hlen) == 0;
  670|      0|	if (!oidmatch || !hashmatch) {
  ------------------
  |  Branch (670:6): [True: 0, False: 0]
  |  Branch (670:19): [True: 0, False: 0]
  ------------------
  671|      0|		ret = SSH_ERR_SIGNATURE_INVALID;
  ------------------
  |  |   45|      0|#define SSH_ERR_SIGNATURE_INVALID		-21
  ------------------
  672|      0|		goto done;
  673|      0|	}
  674|      0|	ret = 0;
  675|     16|done:
  676|     16|	freezero(decrypted, rsasize);
  677|     16|	return ret;
  678|      0|}
ssh-rsa.c:rsa_hash_alg_oid:
  612|     16|{
  613|     16|	switch (hash_alg) {
  614|      7|	case SSH_DIGEST_SHA1:
  ------------------
  |  |   26|      7|#define SSH_DIGEST_SHA1		1
  ------------------
  |  Branch (614:2): [True: 7, False: 9]
  ------------------
  615|      7|		*oidp = id_sha1;
  616|      7|		*oidlenp = sizeof(id_sha1);
  617|      7|		break;
  618|      5|	case SSH_DIGEST_SHA256:
  ------------------
  |  |   27|      5|#define SSH_DIGEST_SHA256	2
  ------------------
  |  Branch (618:2): [True: 5, False: 11]
  ------------------
  619|      5|		*oidp = id_sha256;
  620|      5|		*oidlenp = sizeof(id_sha256);
  621|      5|		break;
  622|      4|	case SSH_DIGEST_SHA512:
  ------------------
  |  |   29|      4|#define SSH_DIGEST_SHA512	4
  ------------------
  |  Branch (622:2): [True: 4, False: 12]
  ------------------
  623|      4|		*oidp = id_sha512;
  624|      4|		*oidlenp = sizeof(id_sha512);
  625|      4|		break;
  626|      0|	default:
  ------------------
  |  Branch (626:2): [True: 0, False: 16]
  ------------------
  627|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  628|     16|	}
  629|     16|	return 0;
  630|     16|}

ssh-xmss.c:ssh_xmss_cleanup:
   44|    409|{
   45|    409|	freezero(k->xmss_pk, sshkey_xmss_pklen(k));
   46|    409|	freezero(k->xmss_sk, sshkey_xmss_sklen(k));
   47|    409|	sshkey_xmss_free_state(k);
   48|    409|	free(k->xmss_name);
   49|    409|	free(k->xmss_filename);
   50|    409|	k->xmss_pk = NULL;
   51|    409|	k->xmss_sk = NULL;
   52|    409|	k->xmss_name = NULL;
   53|    409|	k->xmss_filename = NULL;
   54|    409|}
ssh-xmss.c:ssh_xmss_deserialize_public:
  134|    409|{
  135|    409|	size_t len = 0;
  136|    409|	char *xmss_name = NULL;
  137|    409|	u_char *pk = NULL;
  138|    409|	int ret = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|    409|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  139|       |
  140|    409|	if ((ret = sshbuf_get_cstring(b, &xmss_name, NULL)) != 0)
  ------------------
  |  Branch (140:6): [True: 6, False: 403]
  ------------------
  141|      6|		goto out;
  142|    403|	if ((ret = sshkey_xmss_init(key, xmss_name)) != 0)
  ------------------
  |  Branch (142:6): [True: 150, False: 253]
  ------------------
  143|    150|		goto out;
  144|    253|	if ((ret = sshbuf_get_string(b, &pk, &len)) != 0)
  ------------------
  |  Branch (144:6): [True: 6, False: 247]
  ------------------
  145|      6|		goto out;
  146|    247|	if (len == 0 || len != sshkey_xmss_pklen(key)) {
  ------------------
  |  Branch (146:6): [True: 2, False: 245]
  |  Branch (146:18): [True: 27, False: 218]
  ------------------
  147|     29|		ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|     29|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  148|     29|		goto out;
  149|     29|	}
  150|    218|	key->xmss_pk = pk;
  151|    218|	pk = NULL;
  152|    218|	if (!sshkey_is_cert(key) &&
  ------------------
  |  Branch (152:6): [True: 212, False: 6]
  ------------------
  153|    218|	    (ret = sshkey_xmss_deserialize_pk_info(key, b)) != 0)
  ------------------
  |  Branch (153:6): [True: 24, False: 188]
  ------------------
  154|     24|		goto out;
  155|       |	/* success */
  156|    194|	ret = 0;
  157|    409| out:
  158|    409|	free(xmss_name);
  159|    409|	freezero(pk, len);
  160|    409|	return ret;
  161|    194|}
ssh-xmss.c:ssh_xmss_verify:
  281|    177|{
  282|    177|	struct sshbuf *b = NULL;
  283|    177|	char *ktype = NULL;
  284|    177|	const u_char *sigblob;
  285|    177|	u_char *sm = NULL, *m = NULL;
  286|    177|	size_t len, required_siglen;
  287|    177|	unsigned long long smlen = 0, mlen = 0;
  288|    177|	int r, ret;
  289|       |
  290|    177|	if (key == NULL ||
  ------------------
  |  Branch (290:6): [True: 0, False: 177]
  ------------------
  291|    177|	    sshkey_type_plain(key->type) != KEY_XMSS ||
  ------------------
  |  Branch (291:6): [True: 0, False: 177]
  ------------------
  292|    177|	    key->xmss_pk == NULL ||
  ------------------
  |  Branch (292:6): [True: 0, False: 177]
  ------------------
  293|    177|	    sshkey_xmss_params(key) == NULL ||
  ------------------
  |  Branch (293:6): [True: 0, False: 177]
  ------------------
  294|    177|	    sig == NULL || siglen == 0)
  ------------------
  |  Branch (294:6): [True: 0, False: 177]
  |  Branch (294:21): [True: 0, False: 177]
  ------------------
  295|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  296|    177|	if ((r = sshkey_xmss_siglen(key, &required_siglen)) != 0)
  ------------------
  |  Branch (296:6): [True: 0, False: 177]
  ------------------
  297|      0|		return r;
  298|    177|	if (dlen >= INT_MAX - required_siglen)
  ------------------
  |  Branch (298:6): [True: 0, False: 177]
  ------------------
  299|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  300|       |
  301|    177|	if ((b = sshbuf_from(sig, siglen)) == NULL)
  ------------------
  |  Branch (301:6): [True: 0, False: 177]
  ------------------
  302|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  303|    177|	if ((r = sshbuf_get_cstring(b, &ktype, NULL)) != 0 ||
  ------------------
  |  Branch (303:6): [True: 26, False: 151]
  ------------------
  304|    177|	    (r = sshbuf_get_string_direct(b, &sigblob, &len)) != 0)
  ------------------
  |  Branch (304:6): [True: 4, False: 147]
  ------------------
  305|     30|		goto out;
  306|    147|	if (strcmp("ssh-xmss@openssh.com", ktype) != 0) {
  ------------------
  |  Branch (306:6): [True: 129, False: 18]
  ------------------
  307|    129|		r = SSH_ERR_KEY_TYPE_MISMATCH;
  ------------------
  |  |   37|    129|#define SSH_ERR_KEY_TYPE_MISMATCH		-13
  ------------------
  308|    129|		goto out;
  309|    129|	}
  310|     18|	if (sshbuf_len(b) != 0) {
  ------------------
  |  Branch (310:6): [True: 13, False: 5]
  ------------------
  311|     13|		r = SSH_ERR_UNEXPECTED_TRAILING_DATA;
  ------------------
  |  |   47|     13|#define SSH_ERR_UNEXPECTED_TRAILING_DATA	-23
  ------------------
  312|     13|		goto out;
  313|     13|	}
  314|      5|	if (len != required_siglen) {
  ------------------
  |  Branch (314:6): [True: 5, False: 0]
  ------------------
  315|      5|		r = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      5|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  316|      5|		goto out;
  317|      5|	}
  318|      0|	if (dlen >= SIZE_MAX - len) {
  ------------------
  |  Branch (318:6): [True: 0, False: 0]
  ------------------
  319|      0|		r = SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  320|      0|		goto out;
  321|      0|	}
  322|      0|	smlen = len + dlen;
  323|      0|	mlen = smlen;
  324|      0|	if ((sm = malloc(smlen)) == NULL || (m = malloc(mlen)) == NULL) {
  ------------------
  |  Branch (324:6): [True: 0, False: 0]
  |  Branch (324:38): [True: 0, False: 0]
  ------------------
  325|      0|		r = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  326|      0|		goto out;
  327|      0|	}
  328|      0|	memcpy(sm, sigblob, len);
  329|      0|	memcpy(sm+len, data, dlen);
  330|      0|	if ((ret = xmss_sign_open(m, &mlen, sm, smlen,
  ------------------
  |  Branch (330:6): [True: 0, False: 0]
  ------------------
  331|      0|	    key->xmss_pk, sshkey_xmss_params(key))) != 0) {
  332|      0|		debug2_f("xmss_sign_open failed: %d", ret);
  ------------------
  |  |  101|      0|#define debug2_f(...)		sshlog(__FILE__, __func__, __LINE__, 1, SYSLOG_LEVEL_DEBUG2, NULL, __VA_ARGS__)
  ------------------
  333|      0|	}
  334|      0|	if (ret != 0 || mlen != dlen) {
  ------------------
  |  Branch (334:6): [True: 0, False: 0]
  |  Branch (334:18): [True: 0, False: 0]
  ------------------
  335|      0|		r = SSH_ERR_SIGNATURE_INVALID;
  ------------------
  |  |   45|      0|#define SSH_ERR_SIGNATURE_INVALID		-21
  ------------------
  336|      0|		goto out;
  337|      0|	}
  338|       |	/* XXX compare 'm' and 'data' ? */
  339|       |	/* success */
  340|      0|	r = 0;
  341|    177| out:
  342|    177|	if (sm != NULL)
  ------------------
  |  Branch (342:6): [True: 0, False: 177]
  ------------------
  343|      0|		freezero(sm, smlen);
  344|    177|	if (m != NULL)
  ------------------
  |  Branch (344:6): [True: 0, False: 177]
  ------------------
  345|      0|		freezero(m, smlen);
  346|    177|	sshbuf_free(b);
  347|    177|	free(ktype);
  348|    177|	return r;
  349|      0|}

sshbuf_get_u64:
   49|  4.15k|{
   50|  4.15k|	const u_char *p = sshbuf_ptr(buf);
   51|  4.15k|	int r;
   52|       |
   53|  4.15k|	if ((r = sshbuf_consume(buf, 8)) < 0)
  ------------------
  |  Branch (53:6): [True: 38, False: 4.11k]
  ------------------
   54|     38|		return r;
   55|  4.11k|	if (valp != NULL)
  ------------------
  |  Branch (55:6): [True: 4.11k, False: 0]
  ------------------
   56|  4.11k|		*valp = PEEK_U64(p);
  ------------------
  |  |  335|  4.11k|	(((u_int64_t)(((const u_char *)(p))[0]) << 56) | \
  |  |  336|  4.11k|	 ((u_int64_t)(((const u_char *)(p))[1]) << 48) | \
  |  |  337|  4.11k|	 ((u_int64_t)(((const u_char *)(p))[2]) << 40) | \
  |  |  338|  4.11k|	 ((u_int64_t)(((const u_char *)(p))[3]) << 32) | \
  |  |  339|  4.11k|	 ((u_int64_t)(((const u_char *)(p))[4]) << 24) | \
  |  |  340|  4.11k|	 ((u_int64_t)(((const u_char *)(p))[5]) << 16) | \
  |  |  341|  4.11k|	 ((u_int64_t)(((const u_char *)(p))[6]) << 8) | \
  |  |  342|  4.11k|	  (u_int64_t)(((const u_char *)(p))[7]))
  ------------------
   57|  4.11k|	return 0;
   58|  4.15k|}
sshbuf_get_u32:
   62|  1.64k|{
   63|  1.64k|	const u_char *p = sshbuf_ptr(buf);
   64|  1.64k|	int r;
   65|       |
   66|  1.64k|	if ((r = sshbuf_consume(buf, 4)) < 0)
  ------------------
  |  Branch (66:6): [True: 11, False: 1.63k]
  ------------------
   67|     11|		return r;
   68|  1.63k|	if (valp != NULL)
  ------------------
  |  Branch (68:6): [True: 1.63k, False: 0]
  ------------------
   69|  1.63k|		*valp = PEEK_U32(p);
  ------------------
  |  |  344|  1.63k|	(((u_int32_t)(((const u_char *)(p))[0]) << 24) | \
  |  |  345|  1.63k|	 ((u_int32_t)(((const u_char *)(p))[1]) << 16) | \
  |  |  346|  1.63k|	 ((u_int32_t)(((const u_char *)(p))[2]) << 8) | \
  |  |  347|  1.63k|	  (u_int32_t)(((const u_char *)(p))[3]))
  ------------------
   70|  1.63k|	return 0;
   71|  1.64k|}
sshbuf_get_u8:
   88|    223|{
   89|    223|	const u_char *p = sshbuf_ptr(buf);
   90|    223|	int r;
   91|       |
   92|    223|	if ((r = sshbuf_consume(buf, 1)) < 0)
  ------------------
  |  Branch (92:6): [True: 2, False: 221]
  ------------------
   93|      2|		return r;
   94|    221|	if (valp != NULL)
  ------------------
  |  Branch (94:6): [True: 221, False: 0]
  ------------------
   95|    221|		*valp = (u_int8_t)*p;
   96|    221|	return 0;
   97|    223|}
sshbuf_get_string:
  188|  2.39k|{
  189|  2.39k|	const u_char *val;
  190|  2.39k|	size_t len;
  191|  2.39k|	int r;
  192|       |
  193|  2.39k|	if (valp != NULL)
  ------------------
  |  Branch (193:6): [True: 2.39k, False: 0]
  ------------------
  194|  2.39k|		*valp = NULL;
  195|  2.39k|	if (lenp != NULL)
  ------------------
  |  Branch (195:6): [True: 2.39k, False: 0]
  ------------------
  196|  2.39k|		*lenp = 0;
  197|  2.39k|	if ((r = sshbuf_get_string_direct(buf, &val, &len)) < 0)
  ------------------
  |  Branch (197:6): [True: 115, False: 2.27k]
  ------------------
  198|    115|		return r;
  199|  2.27k|	if (valp != NULL) {
  ------------------
  |  Branch (199:6): [True: 2.27k, False: 0]
  ------------------
  200|  2.27k|		if ((*valp = malloc(len + 1)) == NULL) {
  ------------------
  |  Branch (200:7): [True: 0, False: 2.27k]
  ------------------
  201|      0|			SSHBUF_DBG(("SSH_ERR_ALLOC_FAIL"));
  202|      0|			return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  203|      0|		}
  204|  2.27k|		if (len != 0)
  ------------------
  |  Branch (204:7): [True: 1.89k, False: 379]
  ------------------
  205|  1.89k|			memcpy(*valp, val, len);
  206|  2.27k|		(*valp)[len] = '\0';
  207|  2.27k|	}
  208|  2.27k|	if (lenp != NULL)
  ------------------
  |  Branch (208:6): [True: 2.27k, False: 0]
  ------------------
  209|  2.27k|		*lenp = len;
  210|  2.27k|	return 0;
  211|  2.27k|}
sshbuf_get_string_direct:
  215|  24.2k|{
  216|  24.2k|	size_t len;
  217|  24.2k|	const u_char *p;
  218|  24.2k|	int r;
  219|       |
  220|  24.2k|	if (valp != NULL)
  ------------------
  |  Branch (220:6): [True: 2.91k, False: 21.3k]
  ------------------
  221|  2.91k|		*valp = NULL;
  222|  24.2k|	if (lenp != NULL)
  ------------------
  |  Branch (222:6): [True: 2.91k, False: 21.3k]
  ------------------
  223|  2.91k|		*lenp = 0;
  224|  24.2k|	if ((r = sshbuf_peek_string_direct(buf, &p, &len)) < 0)
  ------------------
  |  Branch (224:6): [True: 270, False: 23.9k]
  ------------------
  225|    270|		return r;
  226|  23.9k|	if (valp != NULL)
  ------------------
  |  Branch (226:6): [True: 2.78k, False: 21.1k]
  ------------------
  227|  2.78k|		*valp = p;
  228|  23.9k|	if (lenp != NULL)
  ------------------
  |  Branch (228:6): [True: 2.78k, False: 21.1k]
  ------------------
  229|  2.78k|		*lenp = len;
  230|  23.9k|	if (sshbuf_consume(buf, len + 4) != 0) {
  ------------------
  |  Branch (230:6): [True: 0, False: 23.9k]
  ------------------
  231|       |		/* Shouldn't happen */
  232|      0|		SSHBUF_DBG(("SSH_ERR_INTERNAL_ERROR"));
  233|      0|		SSHBUF_ABORT();
  234|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  235|      0|	}
  236|  23.9k|	return 0;
  237|  23.9k|}
sshbuf_peek_string_direct:
  242|  46.8k|{
  243|  46.8k|	u_int32_t len;
  244|  46.8k|	const u_char *p = sshbuf_ptr(buf);
  245|       |
  246|  46.8k|	if (valp != NULL)
  ------------------
  |  Branch (246:6): [True: 46.8k, False: 0]
  ------------------
  247|  46.8k|		*valp = NULL;
  248|  46.8k|	if (lenp != NULL)
  ------------------
  |  Branch (248:6): [True: 46.8k, False: 0]
  ------------------
  249|  46.8k|		*lenp = 0;
  250|  46.8k|	if (sshbuf_len(buf) < 4) {
  ------------------
  |  Branch (250:6): [True: 299, False: 46.5k]
  ------------------
  251|    299|		SSHBUF_DBG(("SSH_ERR_MESSAGE_INCOMPLETE"));
  252|    299|		return SSH_ERR_MESSAGE_INCOMPLETE;
  ------------------
  |  |   27|    299|#define SSH_ERR_MESSAGE_INCOMPLETE		-3
  ------------------
  253|    299|	}
  254|  46.5k|	len = PEEK_U32(p);
  ------------------
  |  |  344|  46.5k|	(((u_int32_t)(((const u_char *)(p))[0]) << 24) | \
  |  |  345|  46.5k|	 ((u_int32_t)(((const u_char *)(p))[1]) << 16) | \
  |  |  346|  46.5k|	 ((u_int32_t)(((const u_char *)(p))[2]) << 8) | \
  |  |  347|  46.5k|	  (u_int32_t)(((const u_char *)(p))[3]))
  ------------------
  255|  46.5k|	if (len > SSHBUF_SIZE_MAX - 4) {
  ------------------
  |  |   31|  46.5k|#define SSHBUF_SIZE_MAX		0x8000000	/* Hard maximum size 128MB */
  ------------------
  |  Branch (255:6): [True: 250, False: 46.3k]
  ------------------
  256|    250|		SSHBUF_DBG(("SSH_ERR_STRING_TOO_LARGE"));
  257|    250|		return SSH_ERR_STRING_TOO_LARGE;
  ------------------
  |  |   30|    250|#define SSH_ERR_STRING_TOO_LARGE		-6
  ------------------
  258|    250|	}
  259|  46.3k|	if (sshbuf_len(buf) - 4 < len) {
  ------------------
  |  Branch (259:6): [True: 354, False: 45.9k]
  ------------------
  260|    354|		SSHBUF_DBG(("SSH_ERR_MESSAGE_INCOMPLETE"));
  261|    354|		return SSH_ERR_MESSAGE_INCOMPLETE;
  ------------------
  |  |   27|    354|#define SSH_ERR_MESSAGE_INCOMPLETE		-3
  ------------------
  262|    354|	}
  263|  45.9k|	if (valp != NULL)
  ------------------
  |  Branch (263:6): [True: 45.9k, False: 0]
  ------------------
  264|  45.9k|		*valp = p + 4;
  265|  45.9k|	if (lenp != NULL)
  ------------------
  |  Branch (265:6): [True: 45.9k, False: 0]
  ------------------
  266|  45.9k|		*lenp = len;
  267|  45.9k|	return 0;
  268|  46.3k|}
sshbuf_get_cstring:
  272|  10.5k|{
  273|  10.5k|	size_t len;
  274|  10.5k|	const u_char *p, *z;
  275|  10.5k|	int r;
  276|       |
  277|  10.5k|	if (valp != NULL)
  ------------------
  |  Branch (277:6): [True: 10.5k, False: 0]
  ------------------
  278|  10.5k|		*valp = NULL;
  279|  10.5k|	if (lenp != NULL)
  ------------------
  |  Branch (279:6): [True: 1.43k, False: 9.07k]
  ------------------
  280|  1.43k|		*lenp = 0;
  281|  10.5k|	if ((r = sshbuf_peek_string_direct(buf, &p, &len)) != 0)
  ------------------
  |  Branch (281:6): [True: 314, False: 10.1k]
  ------------------
  282|    314|		return r;
  283|       |	/* Allow a \0 only at the end of the string */
  284|  10.1k|	if (len > 0 &&
  ------------------
  |  Branch (284:6): [True: 5.26k, False: 4.93k]
  ------------------
  285|  10.1k|	    (z = memchr(p , '\0', len)) != NULL && z < p + len - 1) {
  ------------------
  |  Branch (285:6): [True: 536, False: 4.72k]
  |  Branch (285:45): [True: 19, False: 517]
  ------------------
  286|     19|		SSHBUF_DBG(("SSH_ERR_INVALID_FORMAT"));
  287|     19|		return SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|     19|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  288|     19|	}
  289|  10.1k|	if ((r = sshbuf_skip_string(buf)) != 0)
  ------------------
  |  |  237|  10.1k|#define sshbuf_skip_string(buf) sshbuf_get_string_direct(buf, NULL, NULL)
  ------------------
  |  Branch (289:6): [True: 0, False: 10.1k]
  ------------------
  290|      0|		return -1;
  291|  10.1k|	if (valp != NULL) {
  ------------------
  |  Branch (291:6): [True: 10.1k, False: 0]
  ------------------
  292|  10.1k|		if ((*valp = malloc(len + 1)) == NULL) {
  ------------------
  |  Branch (292:7): [True: 0, False: 10.1k]
  ------------------
  293|      0|			SSHBUF_DBG(("SSH_ERR_ALLOC_FAIL"));
  294|      0|			return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  295|      0|		}
  296|  10.1k|		if (len != 0)
  ------------------
  |  Branch (296:7): [True: 5.24k, False: 4.93k]
  ------------------
  297|  5.24k|			memcpy(*valp, p, len);
  298|  10.1k|		(*valp)[len] = '\0';
  299|  10.1k|	}
  300|  10.1k|	if (lenp != NULL)
  ------------------
  |  Branch (300:6): [True: 1.42k, False: 8.75k]
  ------------------
  301|  1.42k|		*lenp = (size_t)len;
  302|  10.1k|	return 0;
  303|  10.1k|}
sshbuf_put:
  327|  3.82k|{
  328|  3.82k|	u_char *p;
  329|  3.82k|	int r;
  330|       |
  331|  3.82k|	if ((r = sshbuf_reserve(buf, len, &p)) < 0)
  ------------------
  |  Branch (331:6): [True: 0, False: 3.82k]
  ------------------
  332|      0|		return r;
  333|  3.82k|	if (len != 0)
  ------------------
  |  Branch (333:6): [True: 1.59k, False: 2.23k]
  ------------------
  334|  1.59k|		memcpy(p, v, len);
  335|  3.82k|	return 0;
  336|  3.82k|}
sshbuf_putb:
  340|  3.77k|{
  341|  3.77k|	if (v == NULL)
  ------------------
  |  Branch (341:6): [True: 0, False: 3.77k]
  ------------------
  342|      0|		return 0;
  343|  3.77k|	return sshbuf_put(buf, sshbuf_ptr(v), sshbuf_len(v));
  344|  3.77k|}
sshbuf_put_u32:
  405|     17|{
  406|     17|	u_char *p;
  407|     17|	int r;
  408|       |
  409|     17|	if ((r = sshbuf_reserve(buf, 4, &p)) < 0)
  ------------------
  |  Branch (409:6): [True: 0, False: 17]
  ------------------
  410|      0|		return r;
  411|     17|	POKE_U32(p, val);
  ------------------
  |  |  365|     17|	do { \
  |  |  366|     17|		const u_int32_t __v = (v); \
  |  |  367|     17|		((u_char *)(p))[0] = (__v >> 24) & 0xff; \
  |  |  368|     17|		((u_char *)(p))[1] = (__v >> 16) & 0xff; \
  |  |  369|     17|		((u_char *)(p))[2] = (__v >> 8) & 0xff; \
  |  |  370|     17|		((u_char *)(p))[3] = __v & 0xff; \
  |  |  371|     17|	} while (0)
  |  |  ------------------
  |  |  |  Branch (371:11): [Folded - Ignored]
  |  |  ------------------
  ------------------
  412|     17|	return 0;
  413|     17|}
sshbuf_put_u8:
  429|     17|{
  430|     17|	u_char *p;
  431|     17|	int r;
  432|       |
  433|     17|	if ((r = sshbuf_reserve(buf, 1, &p)) < 0)
  ------------------
  |  Branch (433:6): [True: 0, False: 17]
  ------------------
  434|      0|		return r;
  435|     17|	p[0] = val;
  436|     17|	return 0;
  437|     17|}
sshbuf_froms:
  548|  5.38k|{
  549|  5.38k|	const u_char *p;
  550|  5.38k|	size_t len;
  551|  5.38k|	struct sshbuf *ret;
  552|  5.38k|	int r;
  553|       |
  554|  5.38k|	if (buf == NULL || bufp == NULL)
  ------------------
  |  Branch (554:6): [True: 0, False: 5.38k]
  |  Branch (554:21): [True: 0, False: 5.38k]
  ------------------
  555|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  556|  5.38k|	*bufp = NULL;
  557|  5.38k|	if ((r = sshbuf_peek_string_direct(buf, &p, &len)) != 0)
  ------------------
  |  Branch (557:6): [True: 93, False: 5.28k]
  ------------------
  558|     93|		return r;
  559|  5.28k|	if ((ret = sshbuf_from(p, len)) == NULL)
  ------------------
  |  Branch (559:6): [True: 0, False: 5.28k]
  ------------------
  560|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  561|  5.28k|	if ((r = sshbuf_consume(buf, len + 4)) != 0 ||  /* Shouldn't happen */
  ------------------
  |  Branch (561:6): [True: 0, False: 5.28k]
  ------------------
  562|  5.28k|	    (r = sshbuf_set_parent(ret, buf)) != 0) {
  ------------------
  |  Branch (562:6): [True: 0, False: 5.28k]
  ------------------
  563|      0|		sshbuf_free(ret);
  564|      0|		return r;
  565|      0|	}
  566|  5.28k|	*bufp = ret;
  567|  5.28k|	return 0;
  568|  5.28k|}
sshbuf_get_bignum2_bytes_direct:
  602|  6.62k|{
  603|  6.62k|	const u_char *d;
  604|  6.62k|	size_t len, olen;
  605|  6.62k|	int r;
  606|       |
  607|  6.62k|	if ((r = sshbuf_peek_string_direct(buf, &d, &olen)) < 0)
  ------------------
  |  Branch (607:6): [True: 158, False: 6.46k]
  ------------------
  608|    158|		return r;
  609|  6.46k|	len = olen;
  610|       |	/* Refuse negative (MSB set) bignums */
  611|  6.46k|	if ((len != 0 && (*d & 0x80) != 0))
  ------------------
  |  Branch (611:7): [True: 537, False: 5.92k]
  |  Branch (611:19): [True: 12, False: 525]
  ------------------
  612|     12|		return SSH_ERR_BIGNUM_IS_NEGATIVE;
  ------------------
  |  |   29|     12|#define SSH_ERR_BIGNUM_IS_NEGATIVE		-5
  ------------------
  613|       |	/* Refuse overlong bignums, allow prepended \0 to avoid MSB set */
  614|  6.45k|	if (len > SSHBUF_MAX_BIGNUM + 1 ||
  ------------------
  |  |   33|  6.45k|#define SSHBUF_MAX_BIGNUM	(16384 / 8)	/* Max bignum *bytes* */
  ------------------
  |  Branch (614:6): [True: 17, False: 6.43k]
  ------------------
  615|  6.45k|	    (len == SSHBUF_MAX_BIGNUM + 1 && *d != 0))
  ------------------
  |  |   33|  6.43k|#define SSHBUF_MAX_BIGNUM	(16384 / 8)	/* Max bignum *bytes* */
  ------------------
  |  Branch (615:7): [True: 20, False: 6.41k]
  |  Branch (615:39): [True: 7, False: 13]
  ------------------
  616|     24|		return SSH_ERR_BIGNUM_TOO_LARGE;
  ------------------
  |  |   31|     24|#define SSH_ERR_BIGNUM_TOO_LARGE		-7
  ------------------
  617|       |	/* Trim leading zeros */
  618|  8.65k|	while (len > 0 && *d == 0x00) {
  ------------------
  |  Branch (618:9): [True: 2.68k, False: 5.97k]
  |  Branch (618:20): [True: 2.23k, False: 454]
  ------------------
  619|  2.23k|		d++;
  620|  2.23k|		len--;
  621|  2.23k|	}
  622|  6.42k|	if (valp != NULL)
  ------------------
  |  Branch (622:6): [True: 6.42k, False: 0]
  ------------------
  623|  6.42k|		*valp = d;
  624|  6.42k|	if (lenp != NULL)
  ------------------
  |  Branch (624:6): [True: 6.42k, False: 0]
  ------------------
  625|  6.42k|		*lenp = len;
  626|  6.42k|	if (sshbuf_consume(buf, olen + 4) != 0) {
  ------------------
  |  Branch (626:6): [True: 0, False: 6.42k]
  ------------------
  627|       |		/* Shouldn't happen */
  628|      0|		SSHBUF_DBG(("SSH_ERR_INTERNAL_ERROR"));
  629|      0|		SSHBUF_ABORT();
  630|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  631|      0|	}
  632|  6.42k|	return 0;
  633|  6.42k|}

sshbuf_get_bignum2:
   37|  6.62k|{
   38|  6.62k|	BIGNUM *v;
   39|  6.62k|	const u_char *d;
   40|  6.62k|	size_t len;
   41|  6.62k|	int r;
   42|       |
   43|  6.62k|	if (valp != NULL)
  ------------------
  |  Branch (43:6): [True: 6.62k, False: 0]
  ------------------
   44|  6.62k|		*valp = NULL;
   45|  6.62k|	if ((r = sshbuf_get_bignum2_bytes_direct(buf, &d, &len)) != 0)
  ------------------
  |  Branch (45:6): [True: 194, False: 6.42k]
  ------------------
   46|    194|		return r;
   47|  6.42k|	if (valp != NULL) {
  ------------------
  |  Branch (47:6): [True: 6.42k, False: 0]
  ------------------
   48|  6.42k|		if ((v = BN_new()) == NULL ||
  ------------------
  |  Branch (48:7): [True: 0, False: 6.42k]
  ------------------
   49|  6.42k|		    BN_bin2bn(d, len, v) == NULL) {
  ------------------
  |  Branch (49:7): [True: 0, False: 6.42k]
  ------------------
   50|      0|			BN_clear_free(v);
   51|      0|			return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
   52|      0|		}
   53|  6.42k|		*valp = v;
   54|  6.42k|	}
   55|  6.42k|	return 0;
   56|  6.42k|}
sshbuf_get_eckey:
   96|    138|{
   97|    138|	EC_POINT *pt = EC_POINT_new(EC_KEY_get0_group(v));
   98|    138|	int r;
   99|    138|	const u_char *d;
  100|    138|	size_t len;
  101|       |
  102|    138|	if (pt == NULL) {
  ------------------
  |  Branch (102:6): [True: 0, False: 138]
  ------------------
  103|      0|		SSHBUF_DBG(("SSH_ERR_ALLOC_FAIL"));
  104|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  105|      0|	}
  106|    138|	if ((r = sshbuf_peek_string_direct(buf, &d, &len)) < 0) {
  ------------------
  |  Branch (106:6): [True: 68, False: 70]
  ------------------
  107|     68|		EC_POINT_free(pt);
  108|     68|		return r;
  109|     68|	}
  110|     70|	if ((r = get_ec(d, len, pt, EC_KEY_get0_group(v))) != 0) {
  ------------------
  |  Branch (110:6): [True: 70, False: 0]
  ------------------
  111|     70|		EC_POINT_free(pt);
  112|     70|		return r;
  113|     70|	}
  114|      0|	if (EC_KEY_set_public_key(v, pt) != 1) {
  ------------------
  |  Branch (114:6): [True: 0, False: 0]
  ------------------
  115|      0|		EC_POINT_free(pt);
  116|      0|		return SSH_ERR_ALLOC_FAIL; /* XXX assumption */
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  117|      0|	}
  118|      0|	EC_POINT_free(pt);
  119|       |	/* Skip string */
  120|      0|	if (sshbuf_get_string_direct(buf, NULL, NULL) != 0) {
  ------------------
  |  Branch (120:6): [True: 0, False: 0]
  ------------------
  121|       |		/* Shouldn't happen */
  122|      0|		SSHBUF_DBG(("SSH_ERR_INTERNAL_ERROR"));
  123|      0|		SSHBUF_ABORT();
  124|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  125|      0|	}
  126|      0|	return 0;
  127|      0|}
sshbuf-getput-crypto.c:get_ec:
   61|     70|{
   62|       |	/* Refuse overlong bignums */
   63|     70|	if (len == 0 || len > SSHBUF_MAX_ECPOINT)
  ------------------
  |  |   34|     48|#define SSHBUF_MAX_ECPOINT	((528 * 2 / 8) + 1) /* Max EC point *bytes* */
  ------------------
  |  Branch (63:6): [True: 22, False: 48]
  |  Branch (63:18): [True: 24, False: 24]
  ------------------
   64|     46|		return SSH_ERR_ECPOINT_TOO_LARGE;
  ------------------
  |  |   32|     46|#define SSH_ERR_ECPOINT_TOO_LARGE		-8
  ------------------
   65|       |	/* Only handle uncompressed points */
   66|     24|	if (*d != POINT_CONVERSION_UNCOMPRESSED)
  ------------------
  |  Branch (66:6): [True: 23, False: 1]
  ------------------
   67|     23|		return SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|     23|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
   68|      1|	if (v != NULL && EC_POINT_oct2point(g, v, d, len, NULL) != 1)
  ------------------
  |  Branch (68:6): [True: 1, False: 0]
  |  Branch (68:19): [True: 1, False: 0]
  ------------------
   69|      1|		return SSH_ERR_INVALID_FORMAT; /* XXX assumption */
  ------------------
  |  |   28|      1|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
   70|      0|	return 0;
   71|      1|}

sshbuf_new_label:
  117|  4.66k|{
  118|  4.66k|	struct sshbuf *ret;
  119|       |
  120|  4.66k|	if ((ret = calloc(sizeof(*ret), 1)) == NULL)
  ------------------
  |  Branch (120:6): [True: 0, False: 4.66k]
  ------------------
  121|      0|		return NULL;
  122|  4.66k|	ret->alloc = SSHBUF_SIZE_INIT;
  ------------------
  |  |  405|  4.66k|# define SSHBUF_SIZE_INIT	256		/* Initial allocation */
  ------------------
  123|  4.66k|	ret->max_size = SSHBUF_SIZE_MAX;
  ------------------
  |  |   31|  4.66k|#define SSHBUF_SIZE_MAX		0x8000000	/* Hard maximum size 128MB */
  ------------------
  124|  4.66k|	ret->readonly = 0;
  125|  4.66k|	ret->refcount = 1;
  126|  4.66k|	ret->parent = NULL;
  127|  4.66k|	if (label != NULL)
  ------------------
  |  Branch (127:6): [True: 4.66k, False: 0]
  ------------------
  128|  4.66k|		strncpy(ret->label, label, MAX_LABEL_LEN-1);
  ------------------
  |  |   35|  4.66k|#define MAX_LABEL_LEN           64 /*maximum size of sshbuf label */
  ------------------
  129|  4.66k|	if ((ret->cd = ret->d = calloc(1, ret->alloc)) == NULL) {
  ------------------
  |  Branch (129:6): [True: 0, False: 4.66k]
  ------------------
  130|      0|		free(ret);
  131|      0|		return NULL;
  132|      0|	}
  133|  4.66k|	return ret;
  134|  4.66k|}
sshbuf_from:
  138|  12.7k|{
  139|  12.7k|	struct sshbuf *ret;
  140|       |
  141|  12.7k|	if (blob == NULL || len > SSHBUF_SIZE_MAX ||
  ------------------
  |  |   31|  25.4k|#define SSHBUF_SIZE_MAX		0x8000000	/* Hard maximum size 128MB */
  ------------------
  |  Branch (141:6): [True: 0, False: 12.7k]
  |  Branch (141:22): [True: 0, False: 12.7k]
  ------------------
  142|  12.7k|	    (ret = calloc(sizeof(*ret), 1)) == NULL)
  ------------------
  |  Branch (142:6): [True: 0, False: 12.7k]
  ------------------
  143|      0|		return NULL;
  144|  12.7k|	ret->alloc = ret->size = ret->max_size = len;
  145|  12.7k|	ret->readonly = 1;
  146|  12.7k|	ret->refcount = 1;
  147|  12.7k|	ret->parent = NULL;
  148|  12.7k|	ret->cd = blob;
  149|  12.7k|	ret->d = NULL;
  150|  12.7k|	return ret;
  151|  12.7k|}
sshbuf_set_parent:
  155|  9.06k|{
  156|  9.06k|	int r;
  157|       |
  158|  9.06k|	if ((r = sshbuf_check_sanity(child)) != 0 ||
  ------------------
  |  Branch (158:6): [True: 0, False: 9.06k]
  ------------------
  159|  9.06k|	    (r = sshbuf_check_sanity(parent)) != 0)
  ------------------
  |  Branch (159:6): [True: 0, False: 9.06k]
  ------------------
  160|      0|		return r;
  161|  9.06k|	if (child->parent != NULL && child->parent != parent)
  ------------------
  |  Branch (161:6): [True: 0, False: 9.06k]
  |  Branch (161:31): [True: 0, False: 0]
  ------------------
  162|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
  163|  9.06k|	child->parent = parent;
  164|  9.06k|	child->parent->refcount++;
  165|  9.06k|	return 0;
  166|  9.06k|}
sshbuf_fromb:
  170|  3.78k|{
  171|  3.78k|	struct sshbuf *ret;
  172|       |
  173|  3.78k|	if (sshbuf_check_sanity(buf) != 0)
  ------------------
  |  Branch (173:6): [True: 0, False: 3.78k]
  ------------------
  174|      0|		return NULL;
  175|  3.78k|	if ((ret = sshbuf_from(sshbuf_ptr(buf), sshbuf_len(buf))) == NULL)
  ------------------
  |  Branch (175:6): [True: 0, False: 3.78k]
  ------------------
  176|      0|		return NULL;
  177|  3.78k|	if (sshbuf_set_parent(ret, buf) != 0) {
  ------------------
  |  Branch (177:6): [True: 0, False: 3.78k]
  ------------------
  178|      0|		sshbuf_free(ret);
  179|      0|		return NULL;
  180|      0|	}
  181|  3.78k|	return ret;
  182|  3.78k|}
sshbuf_free:
  186|  36.1k|{
  187|  36.1k|	if (buf == NULL)
  ------------------
  |  Branch (187:6): [True: 9.67k, False: 26.4k]
  ------------------
  188|  9.67k|		return;
  189|       |	/*
  190|       |	 * The following will leak on insane buffers, but this is the safest
  191|       |	 * course of action - an invalid pointer or already-freed pointer may
  192|       |	 * have been passed to us and continuing to scribble over memory would
  193|       |	 * be bad.
  194|       |	 */
  195|  26.4k|	if (sshbuf_check_sanity(buf) != 0)
  ------------------
  |  Branch (195:6): [True: 0, False: 26.4k]
  ------------------
  196|      0|		return;
  197|       |
  198|       |	/*
  199|       |	 * If we are a parent with still-extant children, then don't free just
  200|       |	 * yet. The last child's call to sshbuf_free should decrement our
  201|       |	 * refcount to 0 and trigger the actual free.
  202|       |	 */
  203|  26.4k|	buf->refcount--;
  204|  26.4k|	if (buf->refcount > 0)
  ------------------
  |  Branch (204:6): [True: 9.06k, False: 17.4k]
  ------------------
  205|  9.06k|		return;
  206|       |
  207|       |	/*
  208|       |	 * If we are a child, the free our parent to decrement its reference
  209|       |	 * count and possibly free it.
  210|       |	 */
  211|  17.4k|	sshbuf_free(buf->parent);
  212|  17.4k|	buf->parent = NULL;
  213|       |
  214|  17.4k|	if (!buf->readonly) {
  ------------------
  |  Branch (214:6): [True: 4.66k, False: 12.7k]
  ------------------
  215|  4.66k|		explicit_bzero(buf->d, buf->alloc);
  216|  4.66k|		free(buf->d);
  217|  4.66k|	}
  218|  17.4k|	freezero(buf, sizeof(*buf));
  219|  17.4k|}
sshbuf_reset:
  223|     73|{
  224|     73|	u_char *d;
  225|       |
  226|     73|	if (buf->readonly || buf->refcount > 1) {
  ------------------
  |  Branch (226:6): [True: 0, False: 73]
  |  Branch (226:23): [True: 0, False: 73]
  ------------------
  227|       |		/* Nonsensical. Just make buffer appear empty */
  228|      0|		buf->off = buf->size;
  229|      0|		return;
  230|      0|	}
  231|     73|	if (sshbuf_check_sanity(buf) != 0)
  ------------------
  |  Branch (231:6): [True: 0, False: 73]
  ------------------
  232|      0|		return;
  233|     73|	buf->off = buf->size = 0;
  234|     73|	if (buf->alloc != SSHBUF_SIZE_INIT) {
  ------------------
  |  |  405|     73|# define SSHBUF_SIZE_INIT	256		/* Initial allocation */
  ------------------
  |  Branch (234:6): [True: 51, False: 22]
  ------------------
  235|     51|		if ((d = recallocarray(buf->d, buf->alloc, SSHBUF_SIZE_INIT,
  ------------------
  |  |  405|     51|# define SSHBUF_SIZE_INIT	256		/* Initial allocation */
  ------------------
  |  Branch (235:7): [True: 51, False: 0]
  ------------------
  236|     51|		    1)) != NULL) {
  237|     51|			buf->cd = buf->d = d;
  238|     51|			buf->alloc = SSHBUF_SIZE_INIT;
  ------------------
  |  |  405|     51|# define SSHBUF_SIZE_INIT	256		/* Initial allocation */
  ------------------
  239|     51|		}
  240|     51|	}
  241|     73|	explicit_bzero(buf->d, buf->alloc);
  242|     73|}
sshbuf_len:
  308|   157k|{
  309|   157k|	if (sshbuf_check_sanity(buf) != 0)
  ------------------
  |  Branch (309:6): [True: 0, False: 157k]
  ------------------
  310|      0|		return 0;
  311|   157k|	return buf->size - buf->off;
  312|   157k|}
sshbuf_ptr:
  335|  61.4k|{
  336|  61.4k|	if (sshbuf_check_sanity(buf) != 0)
  ------------------
  |  Branch (336:6): [True: 0, False: 61.4k]
  ------------------
  337|      0|		return NULL;
  338|  61.4k|	return buf->cd + buf->off;
  339|  61.4k|}
sshbuf_check_reserve:
  351|  4.54k|{
  352|  4.54k|	int r;
  353|       |
  354|  4.54k|	if ((r = sshbuf_check_sanity(buf)) != 0)
  ------------------
  |  Branch (354:6): [True: 0, False: 4.54k]
  ------------------
  355|      0|		return r;
  356|  4.54k|	if (buf->readonly || buf->refcount > 1)
  ------------------
  |  Branch (356:6): [True: 0, False: 4.54k]
  |  Branch (356:23): [True: 0, False: 4.54k]
  ------------------
  357|      0|		return SSH_ERR_BUFFER_READ_ONLY;
  ------------------
  |  |   73|      0|#define SSH_ERR_BUFFER_READ_ONLY		-49
  ------------------
  358|  4.54k|	SSHBUF_TELL("check");
  359|       |	/* Check that len is reasonable and that max_size + available < len */
  360|  4.54k|	if (len > buf->max_size || buf->max_size - len < buf->size - buf->off)
  ------------------
  |  Branch (360:6): [True: 0, False: 4.54k]
  |  Branch (360:29): [True: 0, False: 4.54k]
  ------------------
  361|      0|		return SSH_ERR_NO_BUFFER_SPACE;
  ------------------
  |  |   33|      0|#define SSH_ERR_NO_BUFFER_SPACE			-9
  ------------------
  362|  4.54k|	return 0;
  363|  4.54k|}
sshbuf_allocate:
  367|  3.86k|{
  368|  3.86k|	size_t rlen, need;
  369|  3.86k|	u_char *dp;
  370|  3.86k|	int r;
  371|       |
  372|  3.86k|	SSHBUF_DBG(("allocate buf = %p len = %zu", buf, len));
  373|  3.86k|	if ((r = sshbuf_check_reserve(buf, len)) != 0)
  ------------------
  |  Branch (373:6): [True: 0, False: 3.86k]
  ------------------
  374|      0|		return r;
  375|       |	/*
  376|       |	 * If the requested allocation appended would push us past max_size
  377|       |	 * then pack the buffer, zeroing buf->off.
  378|       |	 */
  379|  3.86k|	sshbuf_maybe_pack(buf, buf->size + len > buf->max_size);
  380|  3.86k|	SSHBUF_TELL("allocate");
  381|  3.86k|	if (len + buf->size <= buf->alloc)
  ------------------
  |  Branch (381:6): [True: 3.17k, False: 685]
  ------------------
  382|  3.17k|		return 0; /* already have it. */
  383|       |
  384|       |	/*
  385|       |	 * Prefer to alloc in SSHBUF_SIZE_INC units, but
  386|       |	 * allocate less if doing so would overflow max_size.
  387|       |	 */
  388|    685|	need = len + buf->size - buf->alloc;
  389|    685|	rlen = ROUNDUP(buf->alloc + need, SSHBUF_SIZE_INC);
  ------------------
  |  |  237|    685|#define ROUNDUP(x, y)   ((((x)+((y)-1))/(y))*(y))
  ------------------
  390|       |	/* With the changes in 8.9 the output buffer end up growing pretty
  391|       |	 * slowly. It's knows that it needs to grow but it only does so 32K
  392|       |	 * at a time. This means a lot of calls to realloc and memcpy which
  393|       |	 * kills performance until the buffer reaches some maximum size.
  394|       |	 * So we explicitly test for a buffer that's trying to grow and
  395|       |	 * if it is then we push the growth by 4MB at a time. This can result in
  396|       |	 * the buffer being over allocated (in terms of actual needs) but the
  397|       |	 * process is fast. This significantly reduces overhead
  398|       |	 * and improves performance. In this case we look for a buffer that is trying
  399|       |	 * to grow larger than BUF_WATERSHED (256*1024 taken from PACKET_MAX_SIZE)
  400|       |	 * and explcitly check that the buffer is being used for inbound outbound
  401|       |	 * channel buffering.
  402|       |	 * Updated for 18.4.1 -cjr 04/20/24
  403|       |	 */
  404|    685|	if (rlen > BUF_WATERSHED && (buf->type == BUF_CHANNEL_OUTPUT || buf->type == BUF_CHANNEL_INPUT)) {
  ------------------
  |  |   32|  1.37k|#define BUF_WATERSHED 256*1024
  ------------------
  |  Branch (404:6): [True: 49, False: 636]
  |  Branch (404:31): [True: 49, False: 0]
  |  Branch (404:66): [True: 0, False: 0]
  ------------------
  405|       |		/* debug_f ("Prior: label: %s, %p, rlen is %zu need is %zu max_size is %zu",
  406|       |		   buf->label, buf, rlen, need, buf->max_size); */
  407|       |		/* easiest thing to do is grow the nuffer by 4MB each time. It might end
  408|       |		 * up being somewhat overallocated but works quickly */
  409|     49|		need = (4*1024*1024);
  410|     49|		rlen = ROUNDUP(buf->alloc + need, SSHBUF_SIZE_INC);
  ------------------
  |  |  237|     49|#define ROUNDUP(x, y)   ((((x)+((y)-1))/(y))*(y))
  ------------------
  411|       |		/* debug_f ("Post: label: %s, %p, rlen is %zu need is %zu max_size is %zu", */
  412|       |		/* 	 buf->label, buf, rlen, need, buf->max_size); */
  413|     49|	}
  414|    685|	SSHBUF_DBG(("need %zu initial rlen %zu", need, rlen));
  415|       |
  416|       |	/* rlen might be above the max allocation */
  417|    685|	if (rlen > buf->max_size)
  ------------------
  |  Branch (417:6): [True: 0, False: 685]
  ------------------
  418|      0|		rlen = buf->max_size;
  419|       |
  420|    685|	SSHBUF_DBG(("adjusted rlen %zu", rlen));
  421|    685|	if ((dp = recallocarray(buf->d, buf->alloc, rlen, 1)) == NULL) {
  ------------------
  |  Branch (421:6): [True: 0, False: 685]
  ------------------
  422|      0|		SSHBUF_DBG(("realloc fail"));
  423|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  424|      0|	}
  425|    685|	buf->alloc = rlen;
  426|    685|	buf->cd = buf->d = dp;
  427|    685|	if ((r = sshbuf_check_reserve(buf, len)) < 0) {
  ------------------
  |  Branch (427:6): [True: 0, False: 685]
  ------------------
  428|       |		/* shouldn't fail */
  429|      0|		return r;
  430|      0|	}
  431|    685|	SSHBUF_TELL("done");
  432|    685|	return 0;
  433|    685|}
sshbuf_reserve:
  437|  3.86k|{
  438|  3.86k|	u_char *dp;
  439|  3.86k|	int r;
  440|       |
  441|  3.86k|	if (dpp != NULL)
  ------------------
  |  Branch (441:6): [True: 3.86k, False: 0]
  ------------------
  442|  3.86k|		*dpp = NULL;
  443|       |
  444|  3.86k|	SSHBUF_DBG(("reserve buf = %p len = %zu", buf, len));
  445|  3.86k|	if ((r = sshbuf_allocate(buf, len)) != 0)
  ------------------
  |  Branch (445:6): [True: 0, False: 3.86k]
  ------------------
  446|      0|		return r;
  447|       |
  448|  3.86k|	dp = buf->d + buf->size;
  449|  3.86k|	buf->size += len;
  450|  3.86k|	if (dpp != NULL)
  ------------------
  |  Branch (450:6): [True: 3.86k, False: 0]
  ------------------
  451|  3.86k|		*dpp = dp;
  452|  3.86k|	return 0;
  453|  3.86k|}
sshbuf_consume:
  457|  41.7k|{
  458|  41.7k|	int r;
  459|       |
  460|  41.7k|	SSHBUF_DBG(("len = %zu", len));
  461|  41.7k|	if ((r = sshbuf_check_sanity(buf)) != 0)
  ------------------
  |  Branch (461:6): [True: 0, False: 41.7k]
  ------------------
  462|      0|		return r;
  463|  41.7k|	if (len == 0)
  ------------------
  |  Branch (463:6): [True: 0, False: 41.7k]
  ------------------
  464|      0|		return 0;
  465|  41.7k|	if (len > sshbuf_len(buf))
  ------------------
  |  Branch (465:6): [True: 51, False: 41.6k]
  ------------------
  466|     51|		return SSH_ERR_MESSAGE_INCOMPLETE;
  ------------------
  |  |   27|     51|#define SSH_ERR_MESSAGE_INCOMPLETE		-3
  ------------------
  467|  41.6k|	buf->off += len;
  468|       |	/* deal with empty buffer */
  469|  41.6k|	if (buf->off == buf->size)
  ------------------
  |  Branch (469:6): [True: 3.52k, False: 38.1k]
  ------------------
  470|  3.52k|		buf->off = buf->size = 0;
  471|  41.6k|	SSHBUF_TELL("done");
  472|  41.6k|	return 0;
  473|  41.7k|}
sshbuf.c:sshbuf_check_sanity:
   80|   313k|{
   81|   313k|	SSHBUF_TELL("sanity");
   82|   313k|	if (__predict_false(buf == NULL ||
  ------------------
  |  |  924|  5.34M|#  define __predict_false(exp)    __builtin_expect(((exp) != 0), 0)
  |  |  ------------------
  |  |  |  Branch (924:35): [True: 0, False: 313k]
  |  |  |  Branch (924:54): [True: 11.6k, False: 302k]
  |  |  |  Branch (924:54): [True: 0, False: 11.6k]
  |  |  |  Branch (924:54): [True: 0, False: 313k]
  |  |  |  Branch (924:54): [True: 0, False: 313k]
  |  |  |  Branch (924:54): [True: 0, False: 313k]
  |  |  |  Branch (924:54): [True: 0, False: 313k]
  |  |  |  Branch (924:54): [True: 0, False: 313k]
  |  |  |  Branch (924:54): [True: 0, False: 313k]
  |  |  |  Branch (924:54): [True: 0, False: 313k]
  |  |  |  Branch (924:54): [True: 0, False: 313k]
  |  |  ------------------
  ------------------
   83|   313k|	    (!buf->readonly && buf->d != buf->cd) ||
   84|   313k|	    buf->refcount < 1 || buf->refcount > SSHBUF_REFS_MAX ||
   85|   313k|	    buf->cd == NULL ||
   86|   313k|	    buf->max_size > SSHBUF_SIZE_MAX ||
   87|   313k|	    buf->alloc > buf->max_size ||
   88|   313k|	    buf->size > buf->alloc ||
   89|   313k|	    buf->off > buf->size)) {
   90|       |		/* Do not try to recover from corrupted buffer internals */
   91|      0|		SSHBUF_DBG(("SSH_ERR_INTERNAL_ERROR"));
   92|      0|		ssh_signal(SIGSEGV, SIG_DFL);
   93|      0|		raise(SIGSEGV);
   94|      0|		return SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|      0|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
   95|      0|	}
   96|   313k|	return 0;
   97|   313k|}
sshbuf.c:sshbuf_maybe_pack:
  101|  3.86k|{
  102|  3.86k|	SSHBUF_DBG(("force %d", force));
  103|  3.86k|	SSHBUF_TELL("pre-pack");
  104|  3.86k|	if (buf->off == 0 || buf->readonly || buf->refcount > 1)
  ------------------
  |  Branch (104:6): [True: 3.86k, False: 0]
  |  Branch (104:23): [True: 0, False: 0]
  |  Branch (104:40): [True: 0, False: 0]
  ------------------
  105|  3.86k|		return;
  106|      0|	if (force ||
  ------------------
  |  Branch (106:6): [True: 0, False: 0]
  ------------------
  107|      0|	    (buf->off >= SSHBUF_PACK_MIN && buf->off >= buf->size / 2)) {
  ------------------
  |  |  407|      0|# define SSHBUF_PACK_MIN	8192		/* Minimum packable offset */
  ------------------
  |  Branch (107:7): [True: 0, False: 0]
  |  Branch (107:38): [True: 0, False: 0]
  ------------------
  108|      0|		memmove(buf->d, buf->d + buf->off, buf->size - buf->off);
  109|      0|		buf->size -= buf->off;
  110|      0|		buf->off = 0;
  111|      0|		SSHBUF_TELL("packed");
  112|      0|	}
  113|      0|}

sshkey_xmss_init:
   96|    403|{
   97|    403|	struct ssh_xmss_state *state;
   98|       |
   99|    403|	if (key->xmss_state != NULL)
  ------------------
  |  Branch (99:6): [True: 0, False: 403]
  ------------------
  100|      0|		return SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  101|    403|	if (name == NULL)
  ------------------
  |  Branch (101:6): [True: 0, False: 403]
  ------------------
  102|      0|		return SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  103|    403|	state = calloc(sizeof(struct ssh_xmss_state), 1);
  104|    403|	if (state == NULL)
  ------------------
  |  Branch (104:6): [True: 0, False: 403]
  ------------------
  105|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  106|    403|	if (strcmp(name, XMSS_SHA2_256_W16_H10_NAME) == 0) {
  ------------------
  |  |   28|    403|#define XMSS_SHA2_256_W16_H10_NAME	"XMSS_SHA2-256_W16_H10"
  ------------------
  |  Branch (106:6): [True: 162, False: 241]
  ------------------
  107|    162|		state->n = 32;
  108|    162|		state->w = 16;
  109|    162|		state->h = 10;
  110|    241|	} else if (strcmp(name, XMSS_SHA2_256_W16_H16_NAME) == 0) {
  ------------------
  |  |   29|    241|#define XMSS_SHA2_256_W16_H16_NAME	"XMSS_SHA2-256_W16_H16"
  ------------------
  |  Branch (110:13): [True: 45, False: 196]
  ------------------
  111|     45|		state->n = 32;
  112|     45|		state->w = 16;
  113|     45|		state->h = 16;
  114|    196|	} else if (strcmp(name, XMSS_SHA2_256_W16_H20_NAME) == 0) {
  ------------------
  |  |   30|    196|#define XMSS_SHA2_256_W16_H20_NAME	"XMSS_SHA2-256_W16_H20"
  ------------------
  |  Branch (114:13): [True: 46, False: 150]
  ------------------
  115|     46|		state->n = 32;
  116|     46|		state->w = 16;
  117|     46|		state->h = 20;
  118|    150|	} else {
  119|    150|		free(state);
  120|    150|		return SSH_ERR_KEY_TYPE_UNKNOWN;
  ------------------
  |  |   38|    150|#define SSH_ERR_KEY_TYPE_UNKNOWN		-14 /* XXX UNSUPPORTED? */
  ------------------
  121|    150|	}
  122|    253|	if ((key->xmss_name = strdup(name)) == NULL) {
  ------------------
  |  Branch (122:6): [True: 0, False: 253]
  ------------------
  123|      0|		free(state);
  124|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
  125|      0|	}
  126|    253|	state->k = 2;	/* XXX hardcoded */
  127|    253|	state->lockfd = -1;
  128|    253|	if (xmss_set_params(&state->params, state->n, state->h, state->w,
  ------------------
  |  Branch (128:6): [True: 0, False: 253]
  ------------------
  129|    253|	    state->k) != 0) {
  130|      0|		free(state);
  131|      0|		return SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  132|      0|	}
  133|    253|	key->xmss_state = state;
  134|    253|	return 0;
  135|    253|}
sshkey_xmss_free_state:
  139|    409|{
  140|    409|	struct ssh_xmss_state *state = key->xmss_state;
  141|       |
  142|    409|	sshkey_xmss_free_bds(key);
  143|    409|	if (state) {
  ------------------
  |  Branch (143:6): [True: 253, False: 156]
  ------------------
  144|    253|		if (state->enc_keyiv) {
  ------------------
  |  Branch (144:7): [True: 0, False: 253]
  ------------------
  145|      0|			explicit_bzero(state->enc_keyiv, state->enc_keyiv_len);
  146|      0|			free(state->enc_keyiv);
  147|      0|		}
  148|    253|		free(state->enc_ciphername);
  149|    253|		free(state);
  150|    253|	}
  151|    409|	key->xmss_state = NULL;
  152|    409|}
sshkey_xmss_free_bds:
  191|    409|{
  192|    409|	struct ssh_xmss_state *state = key->xmss_state;
  193|       |
  194|    409|	if (state == NULL)
  ------------------
  |  Branch (194:6): [True: 156, False: 253]
  ------------------
  195|    156|		return;
  196|    253|	free(state->stack);
  197|    253|	free(state->stacklevels);
  198|    253|	free(state->auth);
  199|    253|	free(state->keep);
  200|    253|	free(state->th_nodes);
  201|    253|	free(state->retain);
  202|    253|	free(state->treehash);
  203|    253|	state->stack = NULL;
  204|    253|	state->stacklevels = NULL;
  205|    253|	state->auth = NULL;
  206|    253|	state->keep = NULL;
  207|    253|	state->th_nodes = NULL;
  208|    253|	state->retain = NULL;
  209|    253|	state->treehash = NULL;
  210|    253|}
sshkey_xmss_params:
  214|    177|{
  215|    177|	struct ssh_xmss_state *state = key->xmss_state;
  216|       |
  217|    177|	if (state == NULL)
  ------------------
  |  Branch (217:6): [True: 0, False: 177]
  ------------------
  218|      0|		return NULL;
  219|    177|	return &state->params;
  220|    177|}
sshkey_xmss_siglen:
  234|    177|{
  235|    177|	struct ssh_xmss_state *state = key->xmss_state;
  236|       |
  237|    177|	if (lenp == NULL)
  ------------------
  |  Branch (237:6): [True: 0, False: 177]
  ------------------
  238|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  239|    177|	if (state == NULL)
  ------------------
  |  Branch (239:6): [True: 0, False: 177]
  ------------------
  240|      0|		return SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      0|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
  241|    177|	*lenp = 4 + state->n +
  242|    177|	    state->params.wots_par.keysize +
  243|    177|	    state->h * state->n;
  244|    177|	return 0;
  245|    177|}
sshkey_xmss_pklen:
  249|    654|{
  250|    654|	struct ssh_xmss_state *state = key->xmss_state;
  251|       |
  252|    654|	if (state == NULL)
  ------------------
  |  Branch (252:6): [True: 156, False: 498]
  ------------------
  253|    156|		return 0;
  254|    498|	return state->n * 2;
  255|    654|}
sshkey_xmss_sklen:
  259|    409|{
  260|    409|	struct ssh_xmss_state *state = key->xmss_state;
  261|       |
  262|    409|	if (state == NULL)
  ------------------
  |  Branch (262:6): [True: 156, False: 253]
  ------------------
  263|    156|		return 0;
  264|    253|	return state->n * 4 + 4;
  265|    409|}
sshkey_xmss_deserialize_pk_info:
  347|    212|{
  348|    212|	struct ssh_xmss_state *state = k->xmss_state;
  349|    212|	u_char have_info;
  350|    212|	int r;
  351|       |
  352|    212|	if (state == NULL)
  ------------------
  |  Branch (352:6): [True: 0, False: 212]
  ------------------
  353|      0|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|      0|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  354|       |	/* optional */
  355|    212|	if (sshbuf_len(b) == 0)
  ------------------
  |  Branch (355:6): [True: 182, False: 30]
  ------------------
  356|    182|		return 0;
  357|     30|	if ((r = sshbuf_get_u8(b, &have_info)) != 0)
  ------------------
  |  Branch (357:6): [True: 0, False: 30]
  ------------------
  358|      0|		return r;
  359|     30|	if (have_info != 1)
  ------------------
  |  Branch (359:6): [True: 20, False: 10]
  ------------------
  360|     20|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|     20|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
  361|     10|	if ((r = sshbuf_get_u32(b, &state->idx)) != 0 ||
  ------------------
  |  Branch (361:6): [True: 1, False: 9]
  ------------------
  362|     10|	    (r = sshbuf_get_u32(b, &state->maxidx)) != 0)
  ------------------
  |  Branch (362:6): [True: 3, False: 6]
  ------------------
  363|      4|		return r;
  364|      6|	return 0;
  365|     10|}

sshkey_type_is_cert:
  230|  13.8k|{
  231|  13.8k|	const struct sshkey_impl *impl;
  232|       |
  233|  13.8k|	if ((impl = sshkey_impl_from_type(type)) == NULL)
  ------------------
  |  Branch (233:6): [True: 3, False: 13.8k]
  ------------------
  234|      3|		return 0;
  235|  13.8k|	return impl->cert;
  236|  13.8k|}
sshkey_ssh_name_plain:
  246|    190|{
  247|    190|	return sshkey_ssh_name_from_type_nid(sshkey_type_plain(k->type),
  248|    190|	    k->ecdsa_nid);
  249|    190|}
sshkey_type_from_name:
  253|  3.65k|{
  254|  3.65k|	int i;
  255|  3.65k|	const struct sshkey_impl *impl;
  256|       |
  257|  48.7k|	for (i = 0; keyimpls[i] != NULL; i++) {
  ------------------
  |  Branch (257:14): [True: 48.4k, False: 265]
  ------------------
  258|  48.4k|		impl = keyimpls[i];
  259|       |		/* Only allow shortname matches for plain key types */
  260|  48.4k|		if ((impl->name != NULL && strcmp(name, impl->name) == 0) ||
  ------------------
  |  Branch (260:8): [True: 48.4k, False: 0]
  |  Branch (260:30): [True: 2.10k, False: 46.3k]
  ------------------
  261|  48.4k|		    (!impl->cert && strcasecmp(impl->shortname, name) == 0))
  ------------------
  |  Branch (261:8): [True: 25.9k, False: 20.4k]
  |  Branch (261:23): [True: 1.28k, False: 24.6k]
  ------------------
  262|  3.38k|			return impl->type;
  263|  48.4k|	}
  264|    265|	return KEY_UNSPEC;
  265|  3.65k|}
sshkey_ecdsa_nid_from_name:
  282|    276|{
  283|    276|	int i;
  284|       |
  285|  1.96k|	for (i = 0; keyimpls[i] != NULL; i++) {
  ------------------
  |  Branch (285:14): [True: 1.95k, False: 10]
  ------------------
  286|  1.95k|		if (!key_type_is_ecdsa_variant(keyimpls[i]->type))
  ------------------
  |  Branch (286:7): [True: 1.20k, False: 751]
  ------------------
  287|  1.20k|			continue;
  288|    751|		if (keyimpls[i]->name != NULL &&
  ------------------
  |  Branch (288:7): [True: 751, False: 0]
  ------------------
  289|    751|		    strcmp(name, keyimpls[i]->name) == 0)
  ------------------
  |  Branch (289:7): [True: 266, False: 485]
  ------------------
  290|    266|			return keyimpls[i]->nid;
  291|    751|	}
  292|     10|	return -1;
  293|    276|}
sshkey_is_cert:
  415|  9.47k|{
  416|  9.47k|	if (k == NULL)
  ------------------
  |  Branch (416:6): [True: 0, False: 9.47k]
  ------------------
  417|      0|		return 0;
  418|  9.47k|	return sshkey_type_is_cert(k->type);
  419|  9.47k|}
sshkey_type_plain:
  438|  1.17k|{
  439|  1.17k|	switch (type) {
  440|      0|	case KEY_RSA_CERT:
  ------------------
  |  Branch (440:2): [True: 0, False: 1.17k]
  ------------------
  441|      0|		return KEY_RSA;
  442|      0|	case KEY_DSA_CERT:
  ------------------
  |  Branch (442:2): [True: 0, False: 1.17k]
  ------------------
  443|      0|		return KEY_DSA;
  444|      0|	case KEY_ECDSA_CERT:
  ------------------
  |  Branch (444:2): [True: 0, False: 1.17k]
  ------------------
  445|      0|		return KEY_ECDSA;
  446|      0|	case KEY_ECDSA_SK_CERT:
  ------------------
  |  Branch (446:2): [True: 0, False: 1.17k]
  ------------------
  447|      0|		return KEY_ECDSA_SK;
  448|      0|	case KEY_ED25519_CERT:
  ------------------
  |  Branch (448:2): [True: 0, False: 1.17k]
  ------------------
  449|      0|		return KEY_ED25519;
  450|      0|	case KEY_ED25519_SK_CERT:
  ------------------
  |  Branch (450:2): [True: 0, False: 1.17k]
  ------------------
  451|      0|		return KEY_ED25519_SK;
  452|      0|	case KEY_XMSS_CERT:
  ------------------
  |  Branch (452:2): [True: 0, False: 1.17k]
  ------------------
  453|      0|		return KEY_XMSS;
  454|  1.17k|	default:
  ------------------
  |  Branch (454:2): [True: 1.17k, False: 0]
  ------------------
  455|  1.17k|		return type;
  456|  1.17k|	}
  457|  1.17k|}
sshkey_curve_name_to_nid:
  487|    256|{
  488|    256|	if (strcmp(name, "nistp256") == 0)
  ------------------
  |  Branch (488:6): [True: 63, False: 193]
  ------------------
  489|     63|		return NID_X9_62_prime256v1;
  490|    193|	else if (strcmp(name, "nistp384") == 0)
  ------------------
  |  Branch (490:11): [True: 42, False: 151]
  ------------------
  491|     42|		return NID_secp384r1;
  492|    151|# ifdef OPENSSL_HAS_NISTP521
  493|    151|	else if (strcmp(name, "nistp521") == 0)
  ------------------
  |  Branch (493:11): [True: 37, False: 114]
  ------------------
  494|     37|		return NID_secp521r1;
  495|    114|# endif /* OPENSSL_HAS_NISTP521 */
  496|    114|	else
  497|    114|		return -1;
  498|    256|}
sshkey_new:
  610|  3.38k|{
  611|  3.38k|	struct sshkey *k;
  612|  3.38k|	const struct sshkey_impl *impl = NULL;
  613|       |
  614|  3.38k|	if (type != KEY_UNSPEC &&
  ------------------
  |  Branch (614:6): [True: 3.38k, False: 0]
  ------------------
  615|  3.38k|	    (impl = sshkey_impl_from_type(type)) == NULL)
  ------------------
  |  Branch (615:6): [True: 0, False: 3.38k]
  ------------------
  616|      0|		return NULL;
  617|       |
  618|       |	/* All non-certificate types may act as CAs */
  619|  3.38k|	if ((k = calloc(1, sizeof(*k))) == NULL)
  ------------------
  |  Branch (619:6): [True: 0, False: 3.38k]
  ------------------
  620|      0|		return NULL;
  621|  3.38k|	k->type = type;
  622|  3.38k|	k->ecdsa_nid = -1;
  623|  3.38k|	if (impl != NULL && impl->funcs->alloc != NULL) {
  ------------------
  |  Branch (623:6): [True: 3.38k, False: 0]
  |  Branch (623:22): [True: 1.99k, False: 1.39k]
  ------------------
  624|  1.99k|		if (impl->funcs->alloc(k) != 0) {
  ------------------
  |  Branch (624:7): [True: 0, False: 1.99k]
  ------------------
  625|      0|			free(k);
  626|      0|			return NULL;
  627|      0|		}
  628|  1.99k|	}
  629|  3.38k|	if (sshkey_is_cert(k)) {
  ------------------
  |  Branch (629:6): [True: 1.55k, False: 1.83k]
  ------------------
  630|  1.55k|		if ((k->cert = cert_new()) == NULL) {
  ------------------
  |  Branch (630:7): [True: 0, False: 1.55k]
  ------------------
  631|      0|			sshkey_free(k);
  632|      0|			return NULL;
  633|      0|		}
  634|  1.55k|	}
  635|       |
  636|  3.38k|	return k;
  637|  3.38k|}
sshkey_sk_cleanup:
  642|    314|{
  643|    314|	free(k->sk_application);
  644|    314|	sshbuf_free(k->sk_key_handle);
  645|    314|	sshbuf_free(k->sk_reserved);
  646|    314|	k->sk_application = NULL;
  647|    314|	k->sk_key_handle = k->sk_reserved = NULL;
  648|    314|}
sshkey_free:
  668|  5.34k|{
  669|  5.34k|	sshkey_free_contents(k);
  670|  5.34k|	freezero(k, sizeof(*k));
  671|  5.34k|}
sshkey_check_rsa_length:
 1332|    322|{
 1333|    322|#ifdef WITH_OPENSSL
 1334|    322|	const BIGNUM *rsa_n;
 1335|    322|	int nbits;
 1336|       |
 1337|    322|	if (k == NULL || k->rsa == NULL ||
  ------------------
  |  Branch (1337:6): [True: 0, False: 322]
  |  Branch (1337:19): [True: 0, False: 322]
  ------------------
 1338|    322|	    (k->type != KEY_RSA && k->type != KEY_RSA_CERT))
  ------------------
  |  Branch (1338:7): [True: 12, False: 310]
  |  Branch (1338:29): [True: 0, False: 12]
  ------------------
 1339|      0|		return 0;
 1340|    322|	RSA_get0_key(k->rsa, &rsa_n, NULL, NULL);
 1341|    322|	nbits = BN_num_bits(rsa_n);
 1342|    322|	if (nbits < SSH_RSA_MINIMUM_MODULUS_SIZE ||
  ------------------
  |  |   53|    644|#define SSH_RSA_MINIMUM_MODULUS_SIZE	1024
  ------------------
  |  Branch (1342:6): [True: 27, False: 295]
  ------------------
 1343|    322|	    (min_size > 0 && nbits < min_size))
  ------------------
  |  Branch (1343:7): [True: 0, False: 295]
  |  Branch (1343:23): [True: 0, False: 0]
  ------------------
 1344|     27|		return SSH_ERR_KEY_LENGTH;
  ------------------
  |  |   80|     27|#define SSH_ERR_KEY_LENGTH			-56
  ------------------
 1345|    295|#endif /* WITH_OPENSSL */
 1346|    295|	return 0;
 1347|    322|}
sshkey_deserialize_sk:
 1891|    287|{
 1892|       |	/* Parse additional security-key application string */
 1893|    287|	if (sshbuf_get_cstring(b, &key->sk_application, NULL) != 0)
  ------------------
  |  Branch (1893:6): [True: 3, False: 284]
  ------------------
 1894|      3|		return SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      3|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 1895|    284|	return 0;
 1896|    287|}
sshkey_from_blob:
 1967|  2.68k|{
 1968|  2.68k|	struct sshbuf *b;
 1969|  2.68k|	int r;
 1970|       |
 1971|  2.68k|	if ((b = sshbuf_from(blob, blen)) == NULL)
  ------------------
  |  Branch (1971:6): [True: 0, False: 2.68k]
  ------------------
 1972|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 1973|  2.68k|	r = sshkey_from_blob_internal(b, keyp, 1);
 1974|  2.68k|	sshbuf_free(b);
 1975|  2.68k|	return r;
 1976|  2.68k|}
sshkey_get_sigtype:
 1999|      1|{
 2000|      1|	int r;
 2001|      1|	struct sshbuf *b = NULL;
 2002|      1|	char *sigtype = NULL;
 2003|       |
 2004|      1|	if (sigtypep != NULL)
  ------------------
  |  Branch (2004:6): [True: 1, False: 0]
  ------------------
 2005|      1|		*sigtypep = NULL;
 2006|      1|	if ((b = sshbuf_from(sig, siglen)) == NULL)
  ------------------
  |  Branch (2006:6): [True: 0, False: 1]
  ------------------
 2007|      0|		return SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 2008|      1|	if ((r = sshbuf_get_cstring(b, &sigtype, NULL)) != 0)
  ------------------
  |  Branch (2008:6): [True: 0, False: 1]
  ------------------
 2009|      0|		goto out;
 2010|       |	/* success */
 2011|      1|	if (sigtypep != NULL) {
  ------------------
  |  Branch (2011:6): [True: 1, False: 0]
  ------------------
 2012|      1|		*sigtypep = sigtype;
 2013|      1|		sigtype = NULL;
 2014|      1|	}
 2015|      1|	r = 0;
 2016|      1| out:
 2017|      1|	free(sigtype);
 2018|      1|	sshbuf_free(b);
 2019|      1|	return r;
 2020|      1|}
sshkey_verify:
 2134|  1.00k|{
 2135|  1.00k|	const struct sshkey_impl *impl;
 2136|       |
 2137|  1.00k|	if (detailsp != NULL)
  ------------------
  |  Branch (2137:6): [True: 0, False: 1.00k]
  ------------------
 2138|      0|		*detailsp = NULL;
 2139|  1.00k|	if (siglen == 0 || dlen > SSH_KEY_MAX_SIGN_DATA_SIZE)
  ------------------
  |  |   54|    988|#define SSH_KEY_MAX_SIGN_DATA_SIZE	(1 << 20)
  ------------------
  |  Branch (2139:6): [True: 14, False: 988]
  |  Branch (2139:21): [True: 0, False: 988]
  ------------------
 2140|     14|		return SSH_ERR_INVALID_ARGUMENT;
  ------------------
  |  |   34|     14|#define SSH_ERR_INVALID_ARGUMENT		-10
  ------------------
 2141|    988|	if ((impl = sshkey_impl_from_key(key)) == NULL)
  ------------------
  |  Branch (2141:6): [True: 0, False: 988]
  ------------------
 2142|      0|		return SSH_ERR_KEY_TYPE_UNKNOWN;
  ------------------
  |  |   38|      0|#define SSH_ERR_KEY_TYPE_UNKNOWN		-14 /* XXX UNSUPPORTED? */
  ------------------
 2143|    988|	return impl->funcs->verify(key, sig, siglen, data, dlen,
 2144|    988|	    alg, compat, detailsp);
 2145|    988|}
sshkey_sig_details_free:
 3622|    215|{
 3623|    215|	freezero(details, sizeof(*details));
 3624|    215|}
sshkey.c:sshkey_impl_from_key:
  202|    988|{
  203|    988|	if (k == NULL)
  ------------------
  |  Branch (203:6): [True: 0, False: 988]
  ------------------
  204|      0|		return NULL;
  205|    988|	return sshkey_impl_from_type_nid(k->type, k->ecdsa_nid);
  206|    988|}
sshkey.c:sshkey_impl_from_type_nid:
  189|  1.17k|{
  190|  1.17k|	int i;
  191|       |
  192|  11.3k|	for (i = 0; keyimpls[i] != NULL; i++) {
  ------------------
  |  Branch (192:14): [True: 11.3k, False: 0]
  ------------------
  193|  11.3k|		if (keyimpls[i]->type == type &&
  ------------------
  |  Branch (193:7): [True: 1.17k, False: 10.1k]
  ------------------
  194|  11.3k|		    (keyimpls[i]->nid == 0 || keyimpls[i]->nid == nid))
  ------------------
  |  Branch (194:8): [True: 1.17k, False: 0]
  |  Branch (194:33): [True: 0, False: 0]
  ------------------
  195|  1.17k|			return keyimpls[i];
  196|  11.3k|	}
  197|      0|	return NULL;
  198|  1.17k|}
sshkey.c:sshkey_impl_from_type:
  177|  25.3k|{
  178|  25.3k|	int i;
  179|       |
  180|   316k|	for (i = 0; keyimpls[i] != NULL; i++) {
  ------------------
  |  Branch (180:14): [True: 316k, False: 268]
  ------------------
  181|   316k|		if (keyimpls[i]->type == type)
  ------------------
  |  Branch (181:7): [True: 25.0k, False: 291k]
  ------------------
  182|  25.0k|			return keyimpls[i];
  183|   316k|	}
  184|    268|	return NULL;
  185|  25.3k|}
sshkey.c:sshkey_ssh_name_from_type_nid:
  220|    190|{
  221|    190|	const struct sshkey_impl *impl;
  222|       |
  223|    190|	if ((impl = sshkey_impl_from_type_nid(type, nid)) == NULL)
  ------------------
  |  Branch (223:6): [True: 0, False: 190]
  ------------------
  224|      0|		return "ssh-unknown";
  225|    190|	return impl->name;
  226|    190|}
sshkey.c:key_type_is_ecdsa_variant:
  269|  1.95k|{
  270|  1.95k|	switch (type) {
  ------------------
  |  Branch (270:10): [True: 1.20k, False: 751]
  ------------------
  271|    488|	case KEY_ECDSA:
  ------------------
  |  Branch (271:2): [True: 488, False: 1.46k]
  ------------------
  272|    716|	case KEY_ECDSA_CERT:
  ------------------
  |  Branch (272:2): [True: 228, False: 1.72k]
  ------------------
  273|    740|	case KEY_ECDSA_SK:
  ------------------
  |  Branch (273:2): [True: 24, False: 1.93k]
  ------------------
  274|    751|	case KEY_ECDSA_SK_CERT:
  ------------------
  |  Branch (274:2): [True: 11, False: 1.94k]
  ------------------
  275|    751|		return 1;
  276|  1.95k|	}
  277|  1.20k|	return 0;
  278|  1.95k|}
sshkey.c:cert_new:
  590|  1.55k|{
  591|  1.55k|	struct sshkey_cert *cert;
  592|       |
  593|  1.55k|	if ((cert = calloc(1, sizeof(*cert))) == NULL)
  ------------------
  |  Branch (593:6): [True: 0, False: 1.55k]
  ------------------
  594|      0|		return NULL;
  595|  1.55k|	if ((cert->certblob = sshbuf_new()) == NULL ||
  ------------------
  |  |   36|  1.55k|#define sshbuf_new() sshbuf_new_label(__func__)
  ------------------
  |  Branch (595:6): [True: 0, False: 1.55k]
  ------------------
  596|  1.55k|	    (cert->critical = sshbuf_new()) == NULL ||
  ------------------
  |  |   36|  1.55k|#define sshbuf_new() sshbuf_new_label(__func__)
  ------------------
  |  Branch (596:6): [True: 0, False: 1.55k]
  ------------------
  597|  1.55k|	    (cert->extensions = sshbuf_new()) == NULL) {
  ------------------
  |  |   36|  1.55k|#define sshbuf_new() sshbuf_new_label(__func__)
  ------------------
  |  Branch (597:6): [True: 0, False: 1.55k]
  ------------------
  598|      0|		cert_free(cert);
  599|      0|		return NULL;
  600|      0|	}
  601|  1.55k|	cert->key_id = NULL;
  602|  1.55k|	cert->principals = NULL;
  603|  1.55k|	cert->signature_key = NULL;
  604|  1.55k|	cert->signature_type = NULL;
  605|  1.55k|	return cert;
  606|  1.55k|}
sshkey.c:sshkey_free_contents:
  652|  5.34k|{
  653|  5.34k|	const struct sshkey_impl *impl;
  654|       |
  655|  5.34k|	if (k == NULL)
  ------------------
  |  Branch (655:6): [True: 1.96k, False: 3.38k]
  ------------------
  656|  1.96k|		return;
  657|  3.38k|	if ((impl = sshkey_impl_from_type(k->type)) != NULL &&
  ------------------
  |  Branch (657:6): [True: 3.38k, False: 0]
  ------------------
  658|  3.38k|	    impl->funcs->cleanup != NULL)
  ------------------
  |  Branch (658:6): [True: 3.38k, False: 0]
  ------------------
  659|  3.38k|		impl->funcs->cleanup(k);
  660|  3.38k|	if (sshkey_is_cert(k))
  ------------------
  |  Branch (660:6): [True: 1.55k, False: 1.83k]
  ------------------
  661|  1.55k|		cert_free(k->cert);
  662|  3.38k|	freezero(k->shielded_private, k->shielded_len);
  663|  3.38k|	freezero(k->shield_prekey, k->shield_prekey_len);
  664|  3.38k|}
sshkey.c:cert_free:
  571|  1.55k|{
  572|  1.55k|	u_int i;
  573|       |
  574|  1.55k|	if (cert == NULL)
  ------------------
  |  Branch (574:6): [True: 0, False: 1.55k]
  ------------------
  575|      0|		return;
  576|  1.55k|	sshbuf_free(cert->certblob);
  577|  1.55k|	sshbuf_free(cert->critical);
  578|  1.55k|	sshbuf_free(cert->extensions);
  579|  1.55k|	free(cert->key_id);
  580|  4.85k|	for (i = 0; i < cert->nprincipals; i++)
  ------------------
  |  Branch (580:14): [True: 3.30k, False: 1.55k]
  ------------------
  581|  3.30k|		free(cert->principals[i]);
  582|  1.55k|	free(cert->principals);
  583|  1.55k|	sshkey_free(cert->signature_key);
  584|  1.55k|	free(cert->signature_type);
  585|  1.55k|	freezero(cert, sizeof(*cert));
  586|  1.55k|}
sshkey.c:sshkey_from_blob_internal:
 1901|  3.78k|{
 1902|  3.78k|	int type, ret = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|  3.78k|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 1903|  3.78k|	char *ktype = NULL;
 1904|  3.78k|	struct sshkey *key = NULL;
 1905|  3.78k|	struct sshbuf *copy;
 1906|  3.78k|	const struct sshkey_impl *impl;
 1907|       |
 1908|       |#ifdef DEBUG_PK /* XXX */
 1909|       |	sshbuf_dump(b, stderr);
 1910|       |#endif
 1911|  3.78k|	if (keyp != NULL)
  ------------------
  |  Branch (1911:6): [True: 3.78k, False: 0]
  ------------------
 1912|  3.78k|		*keyp = NULL;
 1913|  3.78k|	if ((copy = sshbuf_fromb(b)) == NULL) {
  ------------------
  |  Branch (1913:6): [True: 0, False: 3.78k]
  ------------------
 1914|      0|		ret = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 1915|      0|		goto out;
 1916|      0|	}
 1917|  3.78k|	if (sshbuf_get_cstring(b, &ktype, NULL) != 0) {
  ------------------
  |  Branch (1917:6): [True: 129, False: 3.65k]
  ------------------
 1918|    129|		ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|    129|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 1919|    129|		goto out;
 1920|    129|	}
 1921|       |
 1922|  3.65k|	type = sshkey_type_from_name(ktype);
 1923|  3.65k|	if (!allow_cert && sshkey_type_is_cert(type)) {
  ------------------
  |  Branch (1923:6): [True: 1.03k, False: 2.62k]
  |  Branch (1923:21): [True: 4, False: 1.02k]
  ------------------
 1924|      4|		ret = SSH_ERR_KEY_CERT_INVALID_SIGN_KEY;
  ------------------
  |  |   43|      4|#define SSH_ERR_KEY_CERT_INVALID_SIGN_KEY	-19
  ------------------
 1925|      4|		goto out;
 1926|      4|	}
 1927|  3.64k|	if ((impl = sshkey_impl_from_type(type)) == NULL) {
  ------------------
  |  Branch (1927:6): [True: 265, False: 3.38k]
  ------------------
 1928|    265|		ret = SSH_ERR_KEY_TYPE_UNKNOWN;
  ------------------
  |  |   38|    265|#define SSH_ERR_KEY_TYPE_UNKNOWN		-14 /* XXX UNSUPPORTED? */
  ------------------
 1929|    265|		goto out;
 1930|    265|	}
 1931|  3.38k|	if ((key = sshkey_new(type)) == NULL) {
  ------------------
  |  Branch (1931:6): [True: 0, False: 3.38k]
  ------------------
 1932|      0|		ret = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 1933|      0|		goto out;
 1934|      0|	}
 1935|  3.38k|	if (sshkey_type_is_cert(type)) {
  ------------------
  |  Branch (1935:6): [True: 1.55k, False: 1.83k]
  ------------------
 1936|       |		/* Skip nonce that precedes all certificates */
 1937|  1.55k|		if (sshbuf_get_string_direct(b, NULL, NULL) != 0) {
  ------------------
  |  Branch (1937:7): [True: 61, False: 1.48k]
  ------------------
 1938|     61|			ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|     61|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 1939|     61|			goto out;
 1940|     61|		}
 1941|  1.55k|	}
 1942|  3.32k|	if ((ret = impl->funcs->deserialize_public(ktype, b, key)) != 0)
  ------------------
  |  Branch (1942:6): [True: 835, False: 2.48k]
  ------------------
 1943|    835|		goto out;
 1944|       |
 1945|       |	/* Parse certificate potion */
 1946|  2.48k|	if (sshkey_is_cert(key) && (ret = cert_parse(b, key, copy)) != 0)
  ------------------
  |  Branch (1946:6): [True: 1.44k, False: 1.04k]
  |  Branch (1946:29): [True: 1.44k, False: 1]
  ------------------
 1947|  1.44k|		goto out;
 1948|       |
 1949|  1.04k|	if (key != NULL && sshbuf_len(b) != 0) {
  ------------------
  |  Branch (1949:6): [True: 1.04k, False: 0]
  |  Branch (1949:21): [True: 26, False: 1.01k]
  ------------------
 1950|     26|		ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|     26|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 1951|     26|		goto out;
 1952|     26|	}
 1953|  1.01k|	ret = 0;
 1954|  1.01k|	if (keyp != NULL) {
  ------------------
  |  Branch (1954:6): [True: 1.01k, False: 0]
  ------------------
 1955|  1.01k|		*keyp = key;
 1956|  1.01k|		key = NULL;
 1957|  1.01k|	}
 1958|  3.78k| out:
 1959|  3.78k|	sshbuf_free(copy);
 1960|  3.78k|	sshkey_free(key);
 1961|  3.78k|	free(ktype);
 1962|  3.78k|	return ret;
 1963|  1.01k|}
sshkey.c:cert_parse:
 1765|  1.44k|{
 1766|  1.44k|	struct sshbuf *principals = NULL, *crit = NULL;
 1767|  1.44k|	struct sshbuf *exts = NULL, *ca = NULL;
 1768|  1.44k|	u_char *sig = NULL;
 1769|  1.44k|	size_t signed_len = 0, slen = 0, kidlen = 0;
 1770|  1.44k|	int ret = SSH_ERR_INTERNAL_ERROR;
  ------------------
  |  |   25|  1.44k|#define SSH_ERR_INTERNAL_ERROR			-1
  ------------------
 1771|       |
 1772|       |	/* Copy the entire key blob for verification and later serialisation */
 1773|  1.44k|	if ((ret = sshbuf_putb(key->cert->certblob, certbuf)) != 0)
  ------------------
  |  Branch (1773:6): [True: 0, False: 1.44k]
  ------------------
 1774|      0|		return ret;
 1775|       |
 1776|       |	/* Parse body of certificate up to signature */
 1777|  1.44k|	if ((ret = sshbuf_get_u64(b, &key->cert->serial)) != 0 ||
  ------------------
  |  Branch (1777:6): [True: 9, False: 1.43k]
  ------------------
 1778|  1.44k|	    (ret = sshbuf_get_u32(b, &key->cert->type)) != 0 ||
  ------------------
  |  Branch (1778:6): [True: 6, False: 1.43k]
  ------------------
 1779|  1.44k|	    (ret = sshbuf_get_cstring(b, &key->cert->key_id, &kidlen)) != 0 ||
  ------------------
  |  Branch (1779:6): [True: 9, False: 1.42k]
  ------------------
 1780|  1.44k|	    (ret = sshbuf_froms(b, &principals)) != 0 ||
  ------------------
  |  Branch (1780:6): [True: 59, False: 1.36k]
  ------------------
 1781|  1.44k|	    (ret = sshbuf_get_u64(b, &key->cert->valid_after)) != 0 ||
  ------------------
  |  Branch (1781:6): [True: 22, False: 1.34k]
  ------------------
 1782|  1.44k|	    (ret = sshbuf_get_u64(b, &key->cert->valid_before)) != 0 ||
  ------------------
  |  Branch (1782:6): [True: 7, False: 1.33k]
  ------------------
 1783|  1.44k|	    (ret = sshbuf_froms(b, &crit)) != 0 ||
  ------------------
  |  Branch (1783:6): [True: 13, False: 1.32k]
  ------------------
 1784|  1.44k|	    (ret = sshbuf_froms(b, &exts)) != 0 ||
  ------------------
  |  Branch (1784:6): [True: 15, False: 1.30k]
  ------------------
 1785|  1.44k|	    (ret = sshbuf_get_string_direct(b, NULL, NULL)) != 0 ||
  ------------------
  |  Branch (1785:6): [True: 7, False: 1.30k]
  ------------------
 1786|  1.44k|	    (ret = sshbuf_froms(b, &ca)) != 0) {
  ------------------
  |  Branch (1786:6): [True: 6, False: 1.29k]
  ------------------
 1787|       |		/* XXX debug print error for ret */
 1788|    153|		ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|    153|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 1789|    153|		goto out;
 1790|    153|	}
 1791|       |
 1792|       |	/* Signature is left in the buffer so we can calculate this length */
 1793|  1.29k|	signed_len = sshbuf_len(key->cert->certblob) - sshbuf_len(b);
 1794|       |
 1795|  1.29k|	if ((ret = sshbuf_get_string(b, &sig, &slen)) != 0) {
  ------------------
  |  Branch (1795:6): [True: 37, False: 1.25k]
  ------------------
 1796|     37|		ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|     37|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 1797|     37|		goto out;
 1798|     37|	}
 1799|       |
 1800|  1.25k|	if (key->cert->type != SSH2_CERT_TYPE_USER &&
  ------------------
  |  |  179|  2.51k|#define SSH2_CERT_TYPE_USER				1
  ------------------
  |  Branch (1800:6): [True: 491, False: 766]
  ------------------
 1801|  1.25k|	    key->cert->type != SSH2_CERT_TYPE_HOST) {
  ------------------
  |  |  180|    491|#define SSH2_CERT_TYPE_HOST				2
  ------------------
  |  Branch (1801:6): [True: 50, False: 441]
  ------------------
 1802|     50|		ret = SSH_ERR_KEY_CERT_UNKNOWN_TYPE;
  ------------------
  |  |   42|     50|#define SSH_ERR_KEY_CERT_UNKNOWN_TYPE		-18
  ------------------
 1803|     50|		goto out;
 1804|     50|	}
 1805|       |
 1806|       |	/* Parse principals section */
 1807|  4.51k|	while (sshbuf_len(principals) > 0) {
  ------------------
  |  Branch (1807:9): [True: 3.34k, False: 1.16k]
  ------------------
 1808|  3.34k|		char *principal = NULL;
 1809|  3.34k|		char **oprincipals = NULL;
 1810|       |
 1811|  3.34k|		if (key->cert->nprincipals >= SSHKEY_CERT_MAX_PRINCIPALS) {
  ------------------
  |  |  108|  3.34k|#define SSHKEY_CERT_MAX_PRINCIPALS	256
  ------------------
  |  Branch (1811:7): [True: 2, False: 3.34k]
  ------------------
 1812|      2|			ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|      2|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 1813|      2|			goto out;
 1814|      2|		}
 1815|  3.34k|		if ((ret = sshbuf_get_cstring(principals, &principal,
  ------------------
  |  Branch (1815:7): [True: 40, False: 3.30k]
  ------------------
 1816|  3.34k|		    NULL)) != 0) {
 1817|     40|			ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|     40|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 1818|     40|			goto out;
 1819|     40|		}
 1820|  3.30k|		oprincipals = key->cert->principals;
 1821|  3.30k|		key->cert->principals = recallocarray(key->cert->principals,
 1822|  3.30k|		    key->cert->nprincipals, key->cert->nprincipals + 1,
 1823|  3.30k|		    sizeof(*key->cert->principals));
 1824|  3.30k|		if (key->cert->principals == NULL) {
  ------------------
  |  Branch (1824:7): [True: 0, False: 3.30k]
  ------------------
 1825|      0|			free(principal);
 1826|      0|			key->cert->principals = oprincipals;
 1827|      0|			ret = SSH_ERR_ALLOC_FAIL;
  ------------------
  |  |   26|      0|#define SSH_ERR_ALLOC_FAIL			-2
  ------------------
 1828|      0|			goto out;
 1829|      0|		}
 1830|  3.30k|		key->cert->principals[key->cert->nprincipals++] = principal;
 1831|  3.30k|	}
 1832|       |
 1833|       |	/*
 1834|       |	 * Stash a copies of the critical options and extensions sections
 1835|       |	 * for later use.
 1836|       |	 */
 1837|  1.16k|	if ((ret = sshbuf_putb(key->cert->critical, crit)) != 0 ||
  ------------------
  |  Branch (1837:6): [True: 0, False: 1.16k]
  ------------------
 1838|  1.16k|	    (exts != NULL &&
  ------------------
  |  Branch (1838:7): [True: 1.16k, False: 0]
  ------------------
 1839|  1.16k|	    (ret = sshbuf_putb(key->cert->extensions, exts)) != 0))
  ------------------
  |  Branch (1839:6): [True: 0, False: 1.16k]
  ------------------
 1840|      0|		goto out;
 1841|       |
 1842|       |	/*
 1843|       |	 * Validate critical options and extensions sections format.
 1844|       |	 */
 1845|  1.76k|	while (sshbuf_len(crit) != 0) {
  ------------------
  |  Branch (1845:9): [True: 633, False: 1.13k]
  ------------------
 1846|    633|		if ((ret = sshbuf_get_string_direct(crit, NULL, NULL)) != 0 ||
  ------------------
  |  Branch (1846:7): [True: 18, False: 615]
  ------------------
 1847|    633|		    (ret = sshbuf_get_string_direct(crit, NULL, NULL)) != 0) {
  ------------------
  |  Branch (1847:7): [True: 11, False: 604]
  ------------------
 1848|     29|			sshbuf_reset(key->cert->critical);
 1849|     29|			ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|     29|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 1850|     29|			goto out;
 1851|     29|		}
 1852|    633|	}
 1853|  4.63k|	while (exts != NULL && sshbuf_len(exts) != 0) {
  ------------------
  |  Branch (1853:9): [True: 4.63k, False: 0]
  |  Branch (1853:25): [True: 3.53k, False: 1.09k]
  ------------------
 1854|  3.53k|		if ((ret = sshbuf_get_string_direct(exts, NULL, NULL)) != 0 ||
  ------------------
  |  Branch (1854:7): [True: 30, False: 3.50k]
  ------------------
 1855|  3.53k|		    (ret = sshbuf_get_string_direct(exts, NULL, NULL)) != 0) {
  ------------------
  |  Branch (1855:7): [True: 14, False: 3.49k]
  ------------------
 1856|     44|			sshbuf_reset(key->cert->extensions);
 1857|     44|			ret = SSH_ERR_INVALID_FORMAT;
  ------------------
  |  |   28|     44|#define SSH_ERR_INVALID_FORMAT			-4
  ------------------
 1858|     44|			goto out;
 1859|     44|		}
 1860|  3.53k|	}
 1861|       |
 1862|       |	/* Parse CA key and check signature */
 1863|  1.09k|	if (sshkey_from_blob_internal(ca, &key->cert->signature_key, 0) != 0) {
  ------------------
  |  Branch (1863:6): [True: 90, False: 1.00k]
  ------------------
 1864|     90|		ret = SSH_ERR_KEY_CERT_INVALID_SIGN_KEY;
  ------------------
  |  |   43|     90|#define SSH_ERR_KEY_CERT_INVALID_SIGN_KEY	-19
  ------------------
 1865|     90|		goto out;
 1866|     90|	}
 1867|  1.00k|	if (!sshkey_type_is_valid_ca(key->cert->signature_key->type)) {
  ------------------
  |  Branch (1867:6): [True: 0, False: 1.00k]
  ------------------
 1868|      0|		ret = SSH_ERR_KEY_CERT_INVALID_SIGN_KEY;
  ------------------
  |  |   43|      0|#define SSH_ERR_KEY_CERT_INVALID_SIGN_KEY	-19
  ------------------
 1869|      0|		goto out;
 1870|      0|	}
 1871|  1.00k|	if ((ret = sshkey_verify(key->cert->signature_key, sig, slen,
  ------------------
  |  Branch (1871:6): [True: 1.00k, False: 1]
  ------------------
 1872|  1.00k|	    sshbuf_ptr(key->cert->certblob), signed_len, NULL, 0, NULL)) != 0)
 1873|  1.00k|		goto out;
 1874|      1|	if ((ret = sshkey_get_sigtype(sig, slen,
  ------------------
  |  Branch (1874:6): [True: 0, False: 1]
  ------------------
 1875|      1|	    &key->cert->signature_type)) != 0)
 1876|      0|		goto out;
 1877|       |
 1878|       |	/* Success */
 1879|      1|	ret = 0;
 1880|  1.44k| out:
 1881|  1.44k|	sshbuf_free(ca);
 1882|  1.44k|	sshbuf_free(crit);
 1883|  1.44k|	sshbuf_free(exts);
 1884|  1.44k|	sshbuf_free(principals);
 1885|  1.44k|	free(sig);
 1886|  1.44k|	return ret;
 1887|      1|}
sshkey.c:sshkey_type_is_valid_ca:
  404|  1.00k|{
  405|  1.00k|	const struct sshkey_impl *impl;
  406|       |
  407|  1.00k|	if ((impl = sshkey_impl_from_type(type)) == NULL)
  ------------------
  |  Branch (407:6): [True: 0, False: 1.00k]
  ------------------
  408|      0|		return 0;
  409|       |	/* All non-certificate types may act as CAs */
  410|  1.00k|	return !impl->cert;
  411|  1.00k|}

xmss_set_params:
   54|    253|{
   55|    253|  if (k >= h || k < 2 || (h - k) % 2) {
  ------------------
  |  Branch (55:7): [True: 0, False: 253]
  |  Branch (55:17): [True: 0, False: 253]
  |  Branch (55:26): [True: 0, False: 253]
  ------------------
   56|      0|    fprintf(stderr, "For BDS traversal, H - K must be even, with H > K >= 2!\n");
   57|      0|    return 1;
   58|      0|  }
   59|    253|  params->h = h;
   60|    253|  params->n = n;
   61|    253|  params->k = k;
   62|    253|  wots_params wots_par;
   63|    253|  wots_set_params(&wots_par, n, w);
   64|    253|  params->wots_par = wots_par;
   65|    253|  return 0;
   66|    253|}

wots_set_params:
   39|    253|{
   40|    253|  params->n = n;
   41|    253|  params->w = w;
   42|    253|  params->log_w = wots_log2(params->w);
   43|    253|  params->len_1 = (CHAR_BIT * n) / params->log_w;
   44|    253|  params->len_2 = (wots_log2(params->len_1 * (w - 1)) / params->log_w) + 1;
   45|    253|  params->len = params->len_1 + params->len_2;
   46|    253|  params->keysize = params->len * params->n;
   47|    253|}
xmss_wots.c:wots_log2:
   26|    506|{
   27|    506|  int      b;
   28|       |
   29|  12.9k|  for (b = sizeof (v) * CHAR_BIT - 1; b >= 0; b--) {
  ------------------
  |  Branch (29:39): [True: 12.9k, False: 0]
  ------------------
   30|  12.9k|    if ((1U << b) & v) {
  ------------------
  |  Branch (30:9): [True: 506, False: 12.3k]
  ------------------
   31|    506|      return b;
   32|    506|    }
   33|  12.9k|  }
   34|      0|  return 0;
   35|    506|}

