Exemplo n.º 1
0
int nistp256_dh(unsigned char *k, unsigned char *pk, unsigned char *sk) {

    unsigned char kk[crypto_scalarmult_nistp256_BYTES];

    if (pk[0] != 4) return -1;
    if (crypto_scalarmult_nistp256(kk, sk, pk + 1) != 0) return -1;
    byte_copy(k, crypto_scalarmult_nistp256_BYTES / 2, kk);
    purge(kk, sizeof kk);
    return 0;
}
Exemplo n.º 2
0
Arquivo: box.c Projeto: wbl/NISTP
void crypto_box_nistp256aes256gcm_beforenm(unsigned char *k, unsigned char *pk,
        unsigned char *sk) {
    unsigned char temp[64];
    crypto_scalarmult_nistp256(temp, sk, pk);
    memcpy(k, temp, 32); //Magic: copies just x coordinate
}