diff options
Diffstat (limited to 'tools/creative.c')
-rw-r--r-- | tools/creative.c | 103 |
1 files changed, 97 insertions, 6 deletions
diff --git a/tools/creative.c b/tools/creative.c index 1698f58930..5c4a236a52 100644 --- a/tools/creative.c +++ b/tools/creative.c | |||
@@ -23,14 +23,105 @@ | |||
23 | #include <stdbool.h> | 23 | #include <stdbool.h> |
24 | #include <stdlib.h> | 24 | #include <stdlib.h> |
25 | #include <string.h> | 25 | #include <string.h> |
26 | #if !defined(__APPLE__) | ||
27 | #include <elf.h> | ||
28 | #else | ||
29 | #include "mac-elf.h" /* Mac OS X doesn't distribuate elf.h... */ | ||
30 | #endif | ||
31 | |||
32 | #include "creative.h" | 26 | #include "creative.h" |
33 | #include "hmac-sha1.h" | 27 | #include "hmac-sha1.h" |
28 | /* | ||
29 | --------------------------------------------------------------------------- | ||
30 | Shamelessly taken from elf.h (for compatibility reasons included) | ||
31 | --------------------------------------------------------------------------- | ||
32 | |||
33 | This file defines standard ELF types, structures, and macros. | ||
34 | Copyright (C) 1995-2003,2004,2005,2006,2007 Free Software Foundation, Inc. | ||
35 | This file is part of the GNU C Library. | ||
36 | |||
37 | The GNU C Library is free software; you can redistribute it and/or | ||
38 | modify it under the terms of the GNU Lesser General Public | ||
39 | License as published by the Free Software Foundation; either | ||
40 | version 2.1 of the License, or (at your option) any later version. | ||
41 | |||
42 | The GNU C Library is distributed in the hope that it will be useful, | ||
43 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
44 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
45 | Lesser General Public License for more details. | ||
46 | |||
47 | You should have received a copy of the GNU Lesser General Public | ||
48 | License along with the GNU C Library; if not, write to the Free | ||
49 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
50 | 02111-1307 USA. | ||
51 | */ | ||
52 | |||
53 | #include <stdint.h> | ||
54 | |||
55 | /* Type for a 16-bit quantity. */ | ||
56 | typedef uint16_t Elf32_Half; | ||
57 | |||
58 | /* Types for signed and unsigned 32-bit quantities. */ | ||
59 | typedef uint32_t Elf32_Word; | ||
60 | typedef int32_t Elf32_Sword; | ||
61 | |||
62 | /* Types for signed and unsigned 64-bit quantities. */ | ||
63 | typedef uint64_t Elf32_Xword; | ||
64 | typedef int64_t Elf32_Sxword; | ||
65 | |||
66 | /* Type of addresses. */ | ||
67 | typedef uint32_t Elf32_Addr; | ||
68 | |||
69 | /* Type of file offsets. */ | ||
70 | typedef uint32_t Elf32_Off; | ||
71 | |||
72 | /* Type for section indices, which are 16-bit quantities. */ | ||
73 | typedef uint16_t Elf32_Section; | ||
74 | |||
75 | #define EI_NIDENT (16) | ||
76 | |||
77 | typedef struct | ||
78 | { | ||
79 | unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ | ||
80 | Elf32_Half e_type; /* Object file type */ | ||
81 | Elf32_Half e_machine; /* Architecture */ | ||
82 | Elf32_Word e_version; /* Object file version */ | ||
83 | Elf32_Addr e_entry; /* Entry point virtual address */ | ||
84 | Elf32_Off e_phoff; /* Program header table file offset */ | ||
85 | Elf32_Off e_shoff; /* Section header table file offset */ | ||
86 | Elf32_Word e_flags; /* Processor-specific flags */ | ||
87 | Elf32_Half e_ehsize; /* ELF header size in bytes */ | ||
88 | Elf32_Half e_phentsize; /* Program header table entry size */ | ||
89 | Elf32_Half e_phnum; /* Program header table entry count */ | ||
90 | Elf32_Half e_shentsize; /* Section header table entry size */ | ||
91 | Elf32_Half e_shnum; /* Section header table entry count */ | ||
92 | Elf32_Half e_shstrndx; /* Section header string table index */ | ||
93 | } Elf32_Ehdr; | ||
94 | |||
95 | typedef struct | ||
96 | { | ||
97 | Elf32_Word sh_name; /* Section name (string tbl index) */ | ||
98 | Elf32_Word sh_type; /* Section type */ | ||
99 | Elf32_Word sh_flags; /* Section flags */ | ||
100 | Elf32_Addr sh_addr; /* Section virtual addr at execution */ | ||
101 | Elf32_Off sh_offset; /* Section file offset */ | ||
102 | Elf32_Word sh_size; /* Section size in bytes */ | ||
103 | Elf32_Word sh_link; /* Link to another section */ | ||
104 | Elf32_Word sh_info; /* Additional section information */ | ||
105 | Elf32_Word sh_addralign; /* Section alignment */ | ||
106 | Elf32_Word sh_entsize; /* Entry size if section holds table */ | ||
107 | } Elf32_Shdr; | ||
108 | |||
109 | #define ELFMAG0 0x7f /* Magic number byte 0 */ | ||
110 | #define ELFMAG1 'E' /* Magic number byte 1 */ | ||
111 | #define ELFMAG2 'L' /* Magic number byte 2 */ | ||
112 | #define ELFMAG3 'F' /* Magic number byte 3 */ | ||
113 | |||
114 | #define SHF_WRITE (1 << 0) /* Writable */ | ||
115 | #define SHF_ALLOC (1 << 1) /* Occupies memory during execution */ | ||
116 | #define SHF_EXECINSTR (1 << 2) /* Executable */ | ||
117 | |||
118 | #define SHT_NOBITS 8 /* Program space with no data (bss) */ | ||
119 | |||
120 | /* | ||
121 | --------------------------------------------------------------------------- | ||
122 | End of elf.h | ||
123 | --------------------------------------------------------------------------- | ||
124 | */ | ||
34 | 125 | ||
35 | static const char null_key_v1[] = "CTL:N0MAD|PDE0.SIGN."; | 126 | static const char null_key_v1[] = "CTL:N0MAD|PDE0.SIGN."; |
36 | static const char null_key_v2[] = "CTL:N0MAD|PDE0.DPMP."; | 127 | static const char null_key_v2[] = "CTL:N0MAD|PDE0.DPMP."; |