Home | History | Annotate | Download | only in ecc

Lines Matching refs:key

26 static int is_point(ecc_key *key)
36 if ((err = mp_read_radix(prime, key->dp->prime, 16)) != CRYPT_OK) { goto error; }
37 if ((err = mp_read_radix(b, key->dp->B, 16)) != CRYPT_OK) { goto error; }
40 if ((err = mp_sqr(key->pubkey.y, t1)) != CRYPT_OK) { goto error; }
43 if ((err = mp_sqr(key->pubkey.x, t2)) != CRYPT_OK) { goto error; }
45 if ((err = mp_mul(key->pubkey.x, t2, t2)) != CRYPT_OK) { goto error; }
51 if ((err = mp_add(t1, key->pubkey.x, t1)) != CRYPT_OK) { goto error; }
52 if ((err = mp_add(t1, key->pubkey.x, t1)) != CRYPT_OK) { goto error; }
53 if ((err = mp_add(t1, key->pubkey.x, t1)) != CRYPT_OK) { goto error; }
75 Import an ECC key from a binary packet
78 @param key [out] The destination of the import
81 int ecc_import(const unsigned char *in, unsigned long inlen, ecc_key *key)
83 return ecc_import_ex(in, inlen, key, NULL);
87 Import an ECC key from a binary packet, using user supplied domain params rather than one of the NIST ones
90 @param key [out] The destination of the import
94 int ecc_import_ex(const unsigned char *in, unsigned long inlen, ecc_key *key, const ltc_ecc_set_type *dp)
101 LTC_ARGCHK(key != NULL);
104 /* init key */
105 if (mp_init_multi(&key->pubkey.x, &key->pubkey.y, &key->pubkey.z, &key->k, NULL) != CRYPT_OK) {
109 /* find out what type of key it is */
118 /* private key */
119 key->type = PK_PRIVATE;
123 LTC_ASN1_INTEGER, 1UL, key->pubkey.x,
124 LTC_ASN1_INTEGER, 1UL, key->pubkey.y,
125 LTC_ASN1_INTEGER, 1UL, key->k,
130 /* public key */
131 key->type = PK_PUBLIC;
135 LTC_ASN1_INTEGER, 1UL, key->pubkey.x,
136 LTC_ASN1_INTEGER, 1UL, key->pubkey.y,
144 for (key->idx = 0; ltc_ecc_sets[key->idx].size && (unsigned long)ltc_ecc_sets[key->idx].size != key_size; ++key->idx);
145 if (ltc_ecc_sets[key->idx].size == 0) {
149 key->dp = &ltc_ecc_sets[key->idx];
151 key->idx = -1;
152 key->dp = dp;
155 if ((err = mp_set(key->pubkey.z, 1)) != CRYPT_OK) { goto done; }
158 if ((err = is_point(key)) != CRYPT_OK) {
165 mp_clear_multi(key->pubkey.x, key->pubkey.y, key->pubkey.z, key->k, NULL);