xref: /dflybsd-src/usr.sbin/uefisign/magic.h (revision 8e6c217bed2417c878d70765a454bf178418d761)
1bb7548fdSMatthew Dillon /*-
2*8e6c217bSSascha Wildner  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3*8e6c217bSSascha Wildner  *
4bb7548fdSMatthew Dillon  * Copyright (c) 2014 The FreeBSD Foundation
5bb7548fdSMatthew Dillon  * All rights reserved.
6bb7548fdSMatthew Dillon  *
7bb7548fdSMatthew Dillon  * This software was developed by Edward Tomasz Napierala under sponsorship
8bb7548fdSMatthew Dillon  * from the FreeBSD Foundation.
9bb7548fdSMatthew Dillon  *
10bb7548fdSMatthew Dillon  * Redistribution and use in source and binary forms, with or without
11bb7548fdSMatthew Dillon  * modification, are permitted provided that the following conditions
12bb7548fdSMatthew Dillon  * are met:
13bb7548fdSMatthew Dillon  * 1. Redistributions of source code must retain the above copyright
14bb7548fdSMatthew Dillon  *    notice, this list of conditions and the following disclaimer.
15bb7548fdSMatthew Dillon  * 2. Redistributions in binary form must reproduce the above copyright
16bb7548fdSMatthew Dillon  *    notice, this list of conditions and the following disclaimer in the
17bb7548fdSMatthew Dillon  *    documentation and/or other materials provided with the distribution.
18bb7548fdSMatthew Dillon  *
19bb7548fdSMatthew Dillon  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20bb7548fdSMatthew Dillon  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21bb7548fdSMatthew Dillon  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22bb7548fdSMatthew Dillon  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23bb7548fdSMatthew Dillon  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24bb7548fdSMatthew Dillon  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25bb7548fdSMatthew Dillon  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26bb7548fdSMatthew Dillon  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27bb7548fdSMatthew Dillon  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28bb7548fdSMatthew Dillon  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29bb7548fdSMatthew Dillon  * SUCH DAMAGE.
30bb7548fdSMatthew Dillon  *
31*8e6c217bSSascha Wildner  * $FreeBSD: head/usr.sbin/uefisign/magic.h 328335 2018-01-24 16:33:33Z trasz $
32bb7548fdSMatthew Dillon  */
33bb7548fdSMatthew Dillon 
34bb7548fdSMatthew Dillon /*
35bb7548fdSMatthew Dillon  * This file contains Authenticode-specific ASN.1 "configuration", used,
36bb7548fdSMatthew Dillon  * after being processed by asprintf(3), as an input to ASN1_generate_nconf(3).
37bb7548fdSMatthew Dillon  */
38bb7548fdSMatthew Dillon static const char *magic_fmt =
39bb7548fdSMatthew Dillon "asn1 = SEQUENCE:SpcIndirectDataContent\n"
40bb7548fdSMatthew Dillon "\n"
41bb7548fdSMatthew Dillon "[SpcIndirectDataContent]\n"
42bb7548fdSMatthew Dillon "a = SEQUENCE:SpcAttributeTypeAndOptionalValue\n"
43bb7548fdSMatthew Dillon "b = SEQUENCE:DigestInfo\n"
44bb7548fdSMatthew Dillon "\n"
45bb7548fdSMatthew Dillon "[SpcAttributeTypeAndOptionalValue]\n"
46bb7548fdSMatthew Dillon "# SPC_PE_IMAGE_DATAOBJ\n"
47bb7548fdSMatthew Dillon "a = OID:1.3.6.1.4.1.311.2.1.15\n"
48bb7548fdSMatthew Dillon "b = SEQUENCE:SpcPeImageData\n"
49bb7548fdSMatthew Dillon "\n"
50bb7548fdSMatthew Dillon "[SpcPeImageData]\n"
51bb7548fdSMatthew Dillon "a = FORMAT:HEX,BITSTRING:00\n"
52bb7548fdSMatthew Dillon /*
53bb7548fdSMatthew Dillon  * Well, there should be some other struct here, "SPCLink", but it doesn't
54bb7548fdSMatthew Dillon  * appear to be necessary for UEFI, and I have no idea how to synthesize it,
55bb7548fdSMatthew Dillon  * as it uses the CHOICE type.
56bb7548fdSMatthew Dillon  */
57bb7548fdSMatthew Dillon "\n"
58bb7548fdSMatthew Dillon "[DigestInfo]\n"
59bb7548fdSMatthew Dillon "a = SEQUENCE:AlgorithmIdentifier\n"
60bb7548fdSMatthew Dillon /*
61bb7548fdSMatthew Dillon  * Here goes the digest computed from PE headers and sections.
62bb7548fdSMatthew Dillon  */
63bb7548fdSMatthew Dillon "b = FORMAT:HEX,OCTETSTRING:%s\n"
64bb7548fdSMatthew Dillon "\n"
65bb7548fdSMatthew Dillon "[AlgorithmIdentifier]\n"
66bb7548fdSMatthew Dillon "a = OBJECT:sha256\n"
67bb7548fdSMatthew Dillon "b = NULL\n";
68