ecdh.c (d0efb48b8615292e05373caa27854e36e732668b) ecdh.c (6755fd269d5c100b0eca420db501ae58435efd6e)
1/* ECDH key-agreement protocol
2 *
3 * Copyright (c) 2016, Intel Corporation
4 * Authors: Salvator Benedetto <salvatore.benedetto@intel.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version

--- 41 unchanged lines hidden (view full) ---

50
51 ndigits = ecdh_supported_curve(params.curve_id);
52 if (!ndigits)
53 return -EINVAL;
54
55 ctx->curve_id = params.curve_id;
56 ctx->ndigits = ndigits;
57
1/* ECDH key-agreement protocol
2 *
3 * Copyright (c) 2016, Intel Corporation
4 * Authors: Salvator Benedetto <salvatore.benedetto@intel.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version

--- 41 unchanged lines hidden (view full) ---

50
51 ndigits = ecdh_supported_curve(params.curve_id);
52 if (!ndigits)
53 return -EINVAL;
54
55 ctx->curve_id = params.curve_id;
56 ctx->ndigits = ndigits;
57
58 if (!params.key || !params.key_size)
59 return ecc_gen_privkey(ctx->curve_id, ctx->ndigits,
60 ctx->private_key);
61
58 if (ecc_is_key_valid(ctx->curve_id, ctx->ndigits,
59 (const u64 *)params.key, params.key_size) < 0)
60 return -EINVAL;
61
62 memcpy(ctx->private_key, params.key, params.key_size);
63
64 return 0;
65}

--- 84 unchanged lines hidden ---
62 if (ecc_is_key_valid(ctx->curve_id, ctx->ndigits,
63 (const u64 *)params.key, params.key_size) < 0)
64 return -EINVAL;
65
66 memcpy(ctx->private_key, params.key, params.key_size);
67
68 return 0;
69}

--- 84 unchanged lines hidden ---