Lines Matching defs:device

138 static bool do_operation(TrustyKeymasterDevice* device, keymaster_purpose_t purpose,
147 keymaster_error_t error = device->begin(purpose, key, &param_set, nullptr, &op_handle);
153 error = device->update(op_handle, nullptr, input, &input_consumed, nullptr, nullptr);
161 device->abort(op_handle);
164 error = device->finish(op_handle, nullptr, nullptr, signature, nullptr, output);
172 static bool test_import_rsa(TrustyKeymasterDevice* device) {
180 int error = device->import_key(&rsa_param_set, KM_KEY_FORMAT_PKCS8, &private_key, &key, nullptr);
193 if (!do_operation(device, KM_PURPOSE_SIGN, &key, &input, nullptr, &signature)) {
200 if (!do_operation(device, KM_PURPOSE_VERIFY, &key, &input, &signature, nullptr)) {
209 static bool test_rsa(TrustyKeymasterDevice* device) {
216 int error = device->generate_key(&rsa_param_set, &key, nullptr);
229 if (!do_operation(device, KM_PURPOSE_SIGN, &key, &input, nullptr, &signature)) {
236 if (!do_operation(device, KM_PURPOSE_VERIFY, &key, &input, &signature, nullptr)) {
243 error = device->export_key(KM_KEY_FORMAT_X509, &key, nullptr, nullptr, &exported_key);
276 static bool test_import_ecdsa(TrustyKeymasterDevice* device) {
284 int error = device->import_key(&ec_param_set, KM_KEY_FORMAT_PKCS8, &private_key, &key, nullptr);
297 if (!do_operation(device, KM_PURPOSE_SIGN, &key, &input, nullptr, &signature)) {
304 if (!do_operation(device, KM_PURPOSE_VERIFY, &key, &input, &signature, nullptr)) {
313 static bool test_ecdsa(TrustyKeymasterDevice* device) {
320 int error = device->generate_key(&ec_param_set, &key, nullptr);
333 if (!do_operation(device, KM_PURPOSE_SIGN, &key, &input, nullptr, &signature)) {
340 if (!do_operation(device, KM_PURPOSE_VERIFY, &key, &input, &signature, nullptr)) {
347 error = device->export_key(KM_KEY_FORMAT_X509, &key, nullptr, nullptr, &exported_key);
380 TrustyKeymasterDevice device(NULL);
381 keymaster::ConfigureDevice(reinterpret_cast<keymaster2_device_t*>(&device));
382 if (device.session_error() != KM_ERROR_OK) {
383 printf("Failed to initialize Trusty session: %d\n", device.session_error());
389 success &= test_rsa(&device);
390 success &= test_import_rsa(&device);
391 success &= test_ecdsa(&device);
392 success &= test_import_ecdsa(&device);