openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libgcrypt/1.8.4-r0/libgcrypt-1.8.4/cipher/ecc-misc.c
mpi_point_t _gcry_ecc_compute_public(mpi_point_t Q, mpi_ec_t ec, mpi_point_t G,
                                     gcry_mpi_t d)
{
    if (!G)
        G = ec->G;
    if (!d)
        d = ec->d;

    if (!d || !G || !ec->p || !ec->a)
        return NULL;
    if (ec->model == MPI_EC_EDWARDS && !ec->b)
        return NULL;

    if (ec->dialect == ECC_DIALECT_ED25519 && (ec->flags & PUBKEY_FLAG_EDDSA))
    {
        gcry_mpi_t a;
        unsigned char* digest;

        if (_gcry_ecc_eddsa_compute_h_d(&digest, d, ec))
            return NULL;

        a = mpi_snew(0);
        _gcry_mpi_set_buffer(a, digest, 32, 0);
        xfree(digest);

        /* And finally the public key.  */
        if (!Q)
            Q = mpi_point_new(0);
        if (Q)
            _gcry_mpi_ec_mul_point(Q, a, G, ec);
        mpi_free(a);
    }
    else
    {
        if (!Q)
            Q = mpi_point_new(0);
        if (Q)
            _gcry_mpi_ec_mul_point(Q, d, G, ec);
    }

    return Q;
}
/* Compute the public key from the the context EC.  Obviously a
   requirement is that the secret key is available in EC.  On success
   Q is returned; on error NULL.  If Q is NULL a newly allocated point
   is returned.  If G or D are given they override the values taken
   from EC. */
Compute the public key from the the context EC.  Obviously a
requirement is that the secret key is available in EC.  On success
Q is returned; on error NULL.  If Q is NULL a newly allocated point
is returned.  If G or D are given they override the values taken
from EC.
Compute the public key from the the context EC . Obviously a requirement is that the secret key is available in EC . On success Q is returned ; on error NULL . If Q is NULL a newly allocated point is returned . If G or D are given they override the values taken from EC .
mpi_point_t _gcry_ecc_compute_public(mpi_point_t Q, mpi_ec_t ec, mpi_point_t G,
                                     gcry_mpi_t d)
{
    if (!G)
        G = ec->G;
    if (!d)
        d = ec->d;
    if (!d || !G || !ec->p || !ec->a)
        return NULL;
    if (ec->model == MPI_EC_EDWARDS && !ec->b)
        return NULL;
    if (ec->dialect == ECC_DIALECT_ED25519 && (ec->flags & PUBKEY_FLAG_EDDSA))
    {
        gcry_mpi_t a;
        unsigned char* digest;
        if (_gcry_ecc_eddsa_compute_h_d(&digest, d, ec))
            return NULL;
        a = mpi_snew(0);
        _gcry_mpi_set_buffer(a, digest, 32, 0);
        xfree(digest);
        if (!Q)
            Q = mpi_point_new(0);
        if (Q)
            _gcry_mpi_ec_mul_point(Q, a, G, ec);
        mpi_free(a);
    }
    else
    {
        if (!Q)
            Q = mpi_point_new(0);
        if (Q)
            _gcry_mpi_ec_mul_point(Q, d, G, ec);
    }
    return Q;
}
mpi_point_t _gcry_ecc_compute_public ( mpi_point_t Q , mpi_ec_t ec , mpi_point_t G , gcry_mpi_t d ) { if ( ! G ) G = ec -> G ; if ( ! d ) d = ec -> d ; if ( ! d || ! G || ! ec -> p || ! ec -> a ) return NULL ; if ( ec -> model == MPI_EC_EDWARDS && ! ec -> b ) return NULL ; if ( ec -> dialect == ECC_DIALECT_ED25519 && ( ec -> flags & PUBKEY_FLAG_EDDSA ) ) { gcry_mpi_t a ; unsigned char * digest ; if ( _gcry_ecc_eddsa_compute_h_d ( & digest , d , ec ) ) return NULL ; a = mpi_snew ( 0 ) ; _gcry_mpi_set_buffer ( a , digest , 32 , 0 ) ; xfree ( digest ) ; if ( ! Q ) Q = mpi_point_new ( 0 ) ; if ( Q ) _gcry_mpi_ec_mul_point ( Q , a , G , ec ) ; mpi_free ( a ) ; } else { if ( ! Q ) Q = mpi_point_new ( 0 ) ; if ( Q ) _gcry_mpi_ec_mul_point ( Q , d , G , ec ) ; } return Q ; }
Compute the public key from the the context EC.
Compute the public key from the the context EC .
/* And finally the public key.  */