xref: /rk3399_ARM-atf/plat/arm/board/common/rotpk/arm_dev_rotpk.S (revision 06f3c7058c42a9f1a9f7df75ea2de71a000855e8)
1/*
2 * Copyright (c) 2021-2024, ARM Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <plat/arm/board/common/rotpk/rotpk_def.h>
8
9#if ARM_ROTPK_IS_HASH == 1
10	.global arm_rotpk_hash_der_header
11	.global arm_rotpk_hash_end
12	.section .rodata.arm_rotpk_hash, "a"
13
14	#ifndef ARM_ROTPK_HASH_LEN
15	.error "ROTPK hash not defined."
16	#endif
17
18	/*
19	* The rotpk header is dependent only on the algorithm used to
20	* generate the hash.
21	* ASN1_HASH_ALG is the last byte used to encode the OID for
22	* the hash algorithm into the header,
23	* this byte distinguishes between SHA256, SHA384 and SHA512.
24	*/
25	.equ HASH_ASN1_LEN, ARM_ROTPK_HASH_LEN
26	#if ARM_ROTPK_HASH_LEN == 48
27		.equ ASN1_HASH_ALG, 0x02
28		.equ TOTAL_ASN1_LEN, 0x41
29	#elif ARM_ROTPK_HASH_LEN == 64
30		.equ ASN1_HASH_ALG, 0x03
31		.equ TOTAL_ASN1_LEN, 0x51
32	#elif ARM_ROTPK_HASH_LEN == 32
33		.equ ASN1_HASH_ALG, 0x01
34		.equ TOTAL_ASN1_LEN, 0x31
35	#else
36		.error "Invalid ROTPK hash length."
37	#endif
38
39arm_rotpk_hash_der_header:
40	.byte 0x30, TOTAL_ASN1_LEN, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48
41	.byte 0x01, 0x65, 0x03, 0x04, 0x02, ASN1_HASH_ALG, 0x05, 0x00, 0x04, HASH_ASN1_LEN
42arm_rotpk_hash_der_header_len:
43
44#ifdef ARM_ROTPK
45	.incbin ARM_ROTPK
46arm_rotpk_hash_end:
47#endif
48
49	.if ARM_ROTPK_HASH_DER_HEADER_LEN != arm_rotpk_hash_der_header_len - arm_rotpk_hash_der_header
50		.error "Invalid ROTPK header length."
51	.endif
52
53#else
54	/*
55	* The rotpk is an unhashed public key in DER format.
56	* We do not need a header in this case.
57	*/
58	.global arm_rotpk_key
59	.section .rodata.arm_rotpk_key, "a"
60
61arm_rotpk_key:
62	#ifdef ARM_ROTPK
63		.global arm_rotpk_key_end
64		.incbin ARM_ROTPK
65arm_rotpk_key_end:
66	#else
67		.error "ROTPK not found."
68	#endif
69#endif