mirror of
https://github.com/nodemcu/nodemcu-firmware.git
synced 2025-01-16 20:52:57 +08:00
501bd1fb9a
Squashed commit of the following: commit 4439b8c45192f6dee1222df78bbb59f74509e0ee Author: philip <philip@gladstonefamily.net> Date: Sun Mar 6 20:23:21 2016 -0500 Fix the ignore commit a07ee5acdf91286607c3e2dce128c9b8bfd7bd80 Author: philip <philip@gladstonefamily.net> Date: Sun Mar 6 20:20:41 2016 -0500 Remove uneeded stuff commit b3604ace92fc13b30161d385c354b0f1c5fe4046 Author: philip <philip@gladstonefamily.net> Date: Sun Mar 6 20:15:26 2016 -0500 Remove client cert auth commit 6e48c633569630736a986cd07a59a12de954391e Author: philip <philip@gladstonefamily.net> Date: Sun Mar 6 20:11:42 2016 -0500 More cleanup commit d40eade405ef071d0d1b60d038566b5b8f2cafa3 Author: philip <philip@gladstonefamily.net> Date: Sat Mar 5 10:56:56 2016 -0500 Move to almost working version commit 1860a2d90afa94461c53bd41251d4870d6527f9d Author: philip <philip@gladstonefamily.net> Date: Fri Mar 4 08:04:09 2016 -0500 Changed the naem to server-ca.crt commit e7a315660843273fe62943b7fe8ee6c0541dada2 Author: philip <philip@gladstonefamily.net> Date: Thu Mar 3 21:16:26 2016 -0500 Update gitignores commit 2b037d185c396209b64381399c40821c15e1840e Author: philip <philip@gladstonefamily.net> Date: Thu Mar 3 08:56:17 2016 -0500 Getting better commit 763255cffba8e279158cd7f43391a3573efdeca8 Author: philip <philip@gladstonefamily.net> Date: Wed Mar 2 22:28:21 2016 -0500 Works a bit better commit a38325d1a47dbad255cb3e681da8415e8cf699ea Author: philip <philip@gladstonefamily.net> Date: Wed Mar 2 09:11:04 2016 -0500 First building version commit 4aef13da33470ed954f2eaf5f7ac0ac3dcdf3774 Merge: 180e147 ebb0c33 Author: philip <philip@gladstonefamily.net> Date: Tue Mar 1 22:03:06 2016 -0500 Merge remote-tracking branch 'upstream/dev' into ssl-client commit 180e147c1abdcf4046ad9be9b3c1a48f4a875312 Author: philip <philip@gladstonefamily.net> Date: Sun Feb 28 21:34:21 2016 -0500 Missing files from espressif Try to imporve layout Align the file names with the contents Missing file Review comments More review coments
70 lines
1.9 KiB
Python
70 lines
1.9 KiB
Python
import os
|
|
import argparse
|
|
import base64
|
|
import re
|
|
import sys
|
|
|
|
|
|
class Cert(object):
|
|
def __init__(self, name, buff):
|
|
self.name = name
|
|
self.len = len(buff)
|
|
self.buff = buff
|
|
pass
|
|
|
|
def __str__(self):
|
|
out_str = ['\0']*32
|
|
for i in range(len(self.name)):
|
|
out_str[i] = self.name[i]
|
|
out_str = "".join(out_str)
|
|
out_str += str(chr(self.len & 0xFF))
|
|
out_str += str(chr((self.len & 0xFF00) >> 8))
|
|
out_str += self.buff
|
|
return out_str
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description='Convert PEM file(s) into C source file.')
|
|
|
|
parser.add_argument('--section',
|
|
default='.servercert.flash',
|
|
help='specify the section for the data (default is .servercert.flash)')
|
|
|
|
parser.add_argument('--name',
|
|
default='net_server_cert_area',
|
|
help='specify the variable name for the data (default is net_server_cert_area)')
|
|
|
|
parser.add_argument('file', nargs='+',
|
|
help='One or more PEM files')
|
|
|
|
args = parser.parse_args()
|
|
|
|
cert_list = []
|
|
cert_file_list = []
|
|
|
|
for cert_file in args.file:
|
|
with open(cert_file, 'r') as f:
|
|
buff = f.read()
|
|
m = re.search(r"-----BEGIN ([A-Z ]+)-----([^-]+?)-----END \1-----", buff, flags=re.DOTALL)
|
|
if not m:
|
|
sys.exit("Input file was not in PEM format")
|
|
|
|
if "----BEGIN" in buff[m.end(0):]:
|
|
sys.exit("Input file contains more than one PEM object")
|
|
|
|
cert_list.append(Cert(m.group(1), base64.b64decode(''.join(m.group(2).split()))))
|
|
|
|
print '__attribute__((section("%s"))) unsigned char %s[INTERNAL_FLASH_SECTOR_SIZE] = {' % (args.section, args.name)
|
|
for _cert in cert_list:
|
|
col = 0
|
|
for ch in str(_cert):
|
|
print ("0x%02x," % ord(ch)),
|
|
if col & 15 == 15:
|
|
print
|
|
col = col + 1
|
|
print '\n0xff};\n'
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|