|
@@ -0,0 +1,80 @@
|
|
1
|
+/*
|
|
2
|
+ * Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
|
|
3
|
+ *
|
|
4
|
+ * This program is free software; you can redistribute it and/or
|
|
5
|
+ * modify it under the terms of the GNU General Public License as
|
|
6
|
+ * published by the Free Software Foundation; either version 2 of the
|
|
7
|
+ * License, or any later version.
|
|
8
|
+ *
|
|
9
|
+ * This program is distributed in the hope that it will be useful, but
|
|
10
|
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12
|
+ * General Public License for more details.
|
|
13
|
+ *
|
|
14
|
+ * You should have received a copy of the GNU General Public License
|
|
15
|
+ * along with this program; if not, write to the Free Software
|
|
16
|
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
17
|
+ */
|
|
18
|
+
|
|
19
|
+FILE_LICENCE ( GPL2_OR_LATER );
|
|
20
|
+
|
|
21
|
+#include <stdint.h>
|
|
22
|
+#include <ipxe/clientcert.h>
|
|
23
|
+
|
|
24
|
+/** @file
|
|
25
|
+ *
|
|
26
|
+ * Client certificate store
|
|
27
|
+ *
|
|
28
|
+ * Life would in theory be easier if we could use a single file to
|
|
29
|
+ * hold both the certificate and corresponding private key.
|
|
30
|
+ * Unfortunately, the only common format which supports this is
|
|
31
|
+ * PKCS#12 (aka PFX), which is too ugly to be allowed anywhere near my
|
|
32
|
+ * codebase. See, for reference and amusement:
|
|
33
|
+ *
|
|
34
|
+ * http://www.cs.auckland.ac.nz/~pgut001/pubs/pfx.html
|
|
35
|
+ *
|
|
36
|
+ */
|
|
37
|
+
|
|
38
|
+/* Sanity checks */
|
|
39
|
+#if defined(CERTIFICATE) && ! defined(PRIVATE_KEY)
|
|
40
|
+#warning "Attempting to embed certificate with no corresponding private key"
|
|
41
|
+#endif
|
|
42
|
+#if defined(PRIVATE_KEY) && ! defined(CERTIFICATE)
|
|
43
|
+#warning "Attempting to embed private key with no corresponding certificate"
|
|
44
|
+#endif
|
|
45
|
+
|
|
46
|
+/* Raw client certificate data */
|
|
47
|
+extern char client_certificate_data[];
|
|
48
|
+extern char client_certificate_len[];
|
|
49
|
+__asm__ ( ".section \".rodata\", \"a\", @progbits\n\t"
|
|
50
|
+ "\nclient_certificate_data:\n\t"
|
|
51
|
+#ifdef CERTIFICATE
|
|
52
|
+ ".incbin \"" CERTIFICATE "\"\n\t"
|
|
53
|
+#endif /* CERTIFICATE */
|
|
54
|
+ ".size client_certificate_data, ( . - client_certificate_data )\n\t"
|
|
55
|
+ ".equ client_certificate_len, ( . - client_certificate_data )\n\t"
|
|
56
|
+ ".previous\n\t" );
|
|
57
|
+
|
|
58
|
+/** Client certificate */
|
|
59
|
+struct client_certificate client_certificate = {
|
|
60
|
+ .data = client_certificate_data,
|
|
61
|
+ .len = ( ( size_t ) client_certificate_len ),
|
|
62
|
+};
|
|
63
|
+
|
|
64
|
+/* Raw client private key data */
|
|
65
|
+extern char client_private_key_data[];
|
|
66
|
+extern char client_private_key_len[];
|
|
67
|
+__asm__ ( ".section \".rodata\", \"a\", @progbits\n\t"
|
|
68
|
+ "\nclient_private_key_data:\n\t"
|
|
69
|
+#ifdef PRIVATE_KEY
|
|
70
|
+ ".incbin \"" PRIVATE_KEY "\"\n\t"
|
|
71
|
+#endif /* PRIVATE_KEY */
|
|
72
|
+ ".size client_private_key_data, ( . - client_private_key_data )\n\t"
|
|
73
|
+ ".equ client_private_key_len, ( . - client_private_key_data )\n\t"
|
|
74
|
+ ".previous\n\t" );
|
|
75
|
+
|
|
76
|
+/** Client private key */
|
|
77
|
+struct client_private_key client_private_key = {
|
|
78
|
+ .data = client_private_key_data,
|
|
79
|
+ .len = ( ( size_t ) client_private_key_len ),
|
|
80
|
+};
|