Lines Matching +full:- +full:algorithm
2 * Use of this source code is governed by a BSD-style license that can be
23 VbPrivateKey* PrivateKeyReadPem(const char* filename, uint64_t algorithm) { in PrivateKeyReadPem() argument
29 if (algorithm >= kNumAlgorithms) { in PrivateKeyReadPem()
30 VBDEBUG(("%s() called with invalid algorithm!\n", __FUNCTION__)); in PrivateKeyReadPem()
48 /* Store key and algorithm in our struct */ in PrivateKeyReadPem()
54 key->rsa_private_key = rsa_key; in PrivateKeyReadPem()
55 key->algorithm = algorithm; in PrivateKeyReadPem()
65 if (key->rsa_private_key) in PrivateKeyFree()
66 RSA_free(key->rsa_private_key); in PrivateKeyFree()
77 buflen = i2d_RSAPrivateKey(key->rsa_private_key, &outbuf); in PrivateKeyWrite()
90 if (1 != fwrite(&key->algorithm, sizeof(key->algorithm), 1, f)) { in PrivateKeyWrite()
128 key->algorithm = *(typeof(key->algorithm) *)buffer; in PrivateKeyRead()
129 start = buffer + sizeof(key->algorithm); in PrivateKeyRead()
131 key->rsa_private_key = d2i_RSAPrivateKey(0, &start, in PrivateKeyRead()
132 filelen - sizeof(key->algorithm)); in PrivateKeyRead()
134 if (!key->rsa_private_key) { in PrivateKeyRead()
147 VbPublicKey* PublicKeyAlloc(uint64_t key_size, uint64_t algorithm, in PublicKeyAlloc() argument
153 key->algorithm = algorithm; in PublicKeyAlloc()
154 key->key_version = version; in PublicKeyAlloc()
155 key->key_size = key_size; in PublicKeyAlloc()
156 key->key_offset = sizeof(VbPublicKey); in PublicKeyAlloc()
160 VbPublicKey* PublicKeyReadKeyb(const char* filename, uint64_t algorithm, in PublicKeyReadKeyb() argument
167 if (algorithm >= kNumAlgorithms) { in PublicKeyReadKeyb()
168 VBDEBUG(("PublicKeyReadKeyb() called with invalid algorithm!\n")); in PublicKeyReadKeyb()
172 /* Currently, TPM only supports 16-bit version */ in PublicKeyReadKeyb()
181 if (!RSAProcessedKeySize(algorithm, &expected_key_size) || in PublicKeyReadKeyb()
183 VBDEBUG(("PublicKeyReadKeyb() wrong key size for algorithm\n")); in PublicKeyReadKeyb()
188 key = PublicKeyAlloc(key_size, algorithm, version); in PublicKeyReadKeyb()
204 /* Sanity-check key data */ in PublicKeyLooksOkay()
209 if (key->algorithm >= kNumAlgorithms) { in PublicKeyLooksOkay()
210 VBDEBUG(("PublicKeyRead() invalid algorithm\n")); in PublicKeyLooksOkay()
213 if (key->key_version > 0xFFFF) { in PublicKeyLooksOkay()
215 return 0; /* Currently, TPM only supports 16-bit version */ in PublicKeyLooksOkay()
217 if (!RSAProcessedKeySize(key->algorithm, &key_size) || in PublicKeyLooksOkay()
218 key_size != key->key_size) { in PublicKeyLooksOkay()
219 VBDEBUG(("PublicKeyRead() wrong key size for algorithm\n")); in PublicKeyLooksOkay()
250 kcopy = PublicKeyAlloc(key->key_size, 0, 0); in PublicKeyWrite()
259 rv = WriteFile(filename, kcopy, kcopy->key_offset + kcopy->key_size); in PublicKeyWrite()