18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci// Copyright (C) 2020 ARM Limited 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#include <stdio.h> 58c2ecf20Sopenharmony_ci#include <stdlib.h> 68c2ecf20Sopenharmony_ci#include <sys/auxv.h> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include "helper.h" 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciint main(void) 118c2ecf20Sopenharmony_ci{ 128c2ecf20Sopenharmony_ci struct signatures signed_vals; 138c2ecf20Sopenharmony_ci unsigned long hwcaps; 148c2ecf20Sopenharmony_ci size_t val; 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci fread(&val, sizeof(size_t), 1, stdin); 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci /* don't try to execute illegal (unimplemented) instructions) caller 198c2ecf20Sopenharmony_ci * should have checked this and keep worker simple 208c2ecf20Sopenharmony_ci */ 218c2ecf20Sopenharmony_ci hwcaps = getauxval(AT_HWCAP); 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci if (hwcaps & HWCAP_PACA) { 248c2ecf20Sopenharmony_ci signed_vals.keyia = keyia_sign(val); 258c2ecf20Sopenharmony_ci signed_vals.keyib = keyib_sign(val); 268c2ecf20Sopenharmony_ci signed_vals.keyda = keyda_sign(val); 278c2ecf20Sopenharmony_ci signed_vals.keydb = keydb_sign(val); 288c2ecf20Sopenharmony_ci } 298c2ecf20Sopenharmony_ci signed_vals.keyg = (hwcaps & HWCAP_PACG) ? keyg_sign(val) : 0; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci fwrite(&signed_vals, sizeof(struct signatures), 1, stdout); 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci return 0; 348c2ecf20Sopenharmony_ci} 35