Radix cross Linux

The main Radix cross Linux repository contains the build scripts of packages, which have the most complete and common functionality for desktop machines

452 Commits   2 Branches   1 Tag
Index: utils/key2pub.py
===================================================================
--- utils/key2pub.py	(nonexistent)
+++ utils/key2pub.py	(revision 5)
@@ -0,0 +1,172 @@
+#!/usr/bin/env python
+
+import sys
+try:
+       from M2Crypto import RSA
+except ImportError, e:
+       sys.stderr.write('ERROR: Failed to import the "M2Crypto" module: %s\n' % e.message)
+       sys.stderr.write('Please install the "M2Crypto" Python module.\n')
+       sys.stderr.write('On Debian GNU/Linux the package is called "python-m2crypto".\n')
+       sys.exit(1)
+
+def print_ssl_64(format, output, name, val):
+    while val[0] == '\0':
+        val = val[1:]
+    while len(val) % 8:
+        val = '\0' + val
+    vnew = []
+    while len(val):
+        vnew.append((val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]))
+        val = val[8:]
+    vnew.reverse()
+    output.write('static BN_ULONG %s[%d] = {\n' % (name, len(vnew)))
+    idx = 0
+    for v1, v2, v3, v4, v5, v6, v7, v8 in vnew:
+        if not idx:
+            output.write('\t')
+        output.write('0x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x, ' % (ord(v1), ord(v2), ord(v3), ord(v4), ord(v5), ord(v6), ord(v7), ord(v8)))
+        idx += 1
+        if idx == 2:
+            idx = 0
+            output.write('\n')
+    if idx:
+        output.write('\n')
+    output.write('};\n\n')
+
+def print_ssl_32(format, output, name, val):
+    while val[0] == '\0':
+        val = val[1:]
+    while len(val) % 4:
+        val = '\0' + val
+    vnew = []
+    while len(val):
+        vnew.append((val[0], val[1], val[2], val[3], ))
+        val = val[4:]
+    vnew.reverse()
+    output.write('static BN_ULONG %s[%d] = {\n' % (name, len(vnew)))
+    idx = 0
+    for v1, v2, v3, v4 in vnew:
+        if not idx:
+            output.write('\t')
+        output.write('0x%.2x%.2x%.2x%.2x, ' % (ord(v1), ord(v2), ord(v3), ord(v4)))
+        idx += 1
+        if idx == 4:
+            idx = 0
+            output.write('\n')
+    if idx:
+        output.write('\n')
+    output.write('};\n\n')
+
+def print_ssl(format, output, name, val):
+    import struct
+    output.write('#include <stdint.h>\n')
+    output.write('#include <openssl/bn.h>\n')
+    if format == '<Q':
+        return print_ssl_64(format, output, name, val)
+    else:
+        return print_ssl_32(format, output, name, val)
+
+def print_ssl_keys(output, n):
+    output.write(r'''
+struct pubkey {
+	struct bignum_st e, n;
+};
+
+#define KEY(data) {				\
+	.d = data,				\
+	.top = sizeof(data)/sizeof(data[0]),	\
+}
+
+#define KEYS(e,n)	{ KEY(e), KEY(n), }
+
+static struct pubkey keys[] = {
+''')
+    for n in xrange(n + 1):
+        output.write('	KEYS(e_%d, n_%d),\n' % (n, n))
+    output.write('};\n')
+    pass
+
+def print_gcrypt(format, output, name, val):
+    output.write('#include <stdint.h>\n')
+    while val[0] == '\0':
+        val = val[1:]
+    output.write('static const uint8_t %s[%d] = {\n' % (name, len(val)))
+    idx = 0
+    for v in val:
+        if not idx:
+            output.write('\t')
+        output.write('0x%.2x, ' % ord(v))
+        idx += 1
+        if idx == 8:
+            idx = 0
+            output.write('\n')
+    if idx:
+        output.write('\n')
+    output.write('};\n\n')
+
+def print_gcrypt_keys(output, n):
+    output.write(r'''
+struct key_params {
+	const uint8_t *e, *n;
+	uint32_t len_e, len_n;
+};
+
+#define KEYS(_e, _n) {			\
+	.e = _e, .len_e = sizeof(_e),	\
+	.n = _n, .len_n = sizeof(_n),	\
+}
+
+static const struct key_params __attribute__ ((unused)) keys[] = {
+''')
+    for n in xrange(n + 1):
+        output.write('	KEYS(e_%d, n_%d),\n' % (n, n))
+    output.write('};\n')
+    
+
+
+formats = {
+    '--le64': ('<','Q'),
+    '--le32': ('<','L'),
+}
+
+modes = {
+    '--ssl': (print_ssl, print_ssl_keys),
+    '--gcrypt': (print_gcrypt, print_gcrypt_keys),
+}
+
+try:
+    mode = sys.argv[1]
+    format = sys.argv[2]
+    files = sys.argv[3:-1]
+    outfile = sys.argv[-1]
+except IndexError:
+    mode = None
+    format = None
+
+if not mode in modes:
+    print 'Usage: %s [%s] [%s] input-file... output-file' % (sys.argv[0], '|'.join(modes.keys()), '--format')
+    sys.exit(2)
+
+if not format in formats.keys():
+    print 'Usage: %s [%s] [%s] input-file... output-file' % (sys.argv[0], '--mode', '|'.join(formats.keys()))
+    sys.exit(2)
+
+
+data_format = '%s%s' % (formats[format][0], formats[format][1])
+
+
+output = open(outfile, 'w')
+
+# load key
+idx = 0
+for f in files:
+    try:
+        key = RSA.load_pub_key(f)
+    except RSA.RSAError:
+        key = RSA.load_key(f)
+
+    modes[mode][0](data_format, output, 'e_%d' % idx, key.e[4:])
+    modes[mode][0](data_format, output, 'n_%d' % idx, key.n[4:])
+    idx += 1
+
+modes[mode][1](output, idx - 1)

Property changes on: utils/key2pub.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: utils
===================================================================
--- utils	(nonexistent)
+++ utils	(revision 5)

Property changes on: utils
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: .
===================================================================
--- .	(nonexistent)
+++ .	(revision 5)

Property changes on: .
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~