xref: /arm-trusted-firmware/plat/arm/board/n1sdp/n1sdp_trusted_boot.c (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700Schasinglulu /*
2*91f16700Schasinglulu  * Copyright (c) 2022, Arm Limited. All rights reserved.
3*91f16700Schasinglulu  *
4*91f16700Schasinglulu  * SPDX-License-Identifier: BSD-3-Clause
5*91f16700Schasinglulu  */
6*91f16700Schasinglulu 
7*91f16700Schasinglulu #include <stdint.h>
8*91f16700Schasinglulu 
9*91f16700Schasinglulu #include <plat/arm/common/plat_arm.h>
10*91f16700Schasinglulu 
11*91f16700Schasinglulu /*
12*91f16700Schasinglulu  * Return the non-volatile counter value stored in the platform. The cookie
13*91f16700Schasinglulu  * will contain the OID of the counter in the certificate.
14*91f16700Schasinglulu  *
15*91f16700Schasinglulu  * Return: 0 = success, Otherwise = error
16*91f16700Schasinglulu  */
17*91f16700Schasinglulu int plat_get_nv_ctr(void *cookie, unsigned int *nv_ctr)
18*91f16700Schasinglulu {
19*91f16700Schasinglulu 	*nv_ctr = N1SDP_FW_NVCTR_VAL;
20*91f16700Schasinglulu 	return 0;
21*91f16700Schasinglulu }
22*91f16700Schasinglulu 
23*91f16700Schasinglulu /*
24*91f16700Schasinglulu  * Store a new non-volatile counter value. By default on ARM development
25*91f16700Schasinglulu  * platforms, the non-volatile counters are RO and cannot be modified. We expect
26*91f16700Schasinglulu  * the values in the certificates to always match the RO values so that this
27*91f16700Schasinglulu  * function is never called.
28*91f16700Schasinglulu  *
29*91f16700Schasinglulu  * Return: 0 = success, Otherwise = error
30*91f16700Schasinglulu  */
31*91f16700Schasinglulu int plat_set_nv_ctr(void *cookie, unsigned int nv_ctr)
32*91f16700Schasinglulu {
33*91f16700Schasinglulu 	return 1;
34*91f16700Schasinglulu }
35*91f16700Schasinglulu 
36*91f16700Schasinglulu /*
37*91f16700Schasinglulu  * Return the ROTPK hash in the following ASN.1 structure in DER format:
38*91f16700Schasinglulu  *
39*91f16700Schasinglulu  * AlgorithmIdentifier  ::=  SEQUENCE  {
40*91f16700Schasinglulu  *     algorithm         OBJECT IDENTIFIER,
41*91f16700Schasinglulu  *     parameters        ANY DEFINED BY algorithm OPTIONAL
42*91f16700Schasinglulu  * }
43*91f16700Schasinglulu  *
44*91f16700Schasinglulu  * DigestInfo ::= SEQUENCE {
45*91f16700Schasinglulu  *     digestAlgorithm   AlgorithmIdentifier,
46*91f16700Schasinglulu  *     digest            OCTET STRING
47*91f16700Schasinglulu  * }
48*91f16700Schasinglulu  */
49*91f16700Schasinglulu int plat_get_rotpk_info(void *cookie, void **key_ptr, unsigned int *key_len,
50*91f16700Schasinglulu 			 unsigned int *flags)
51*91f16700Schasinglulu {
52*91f16700Schasinglulu 	return arm_get_rotpk_info(cookie, key_ptr, key_len, flags);
53*91f16700Schasinglulu }
54*91f16700Schasinglulu 
55