aboutsummaryrefslogtreecommitdiffstats
path: root/meta-networking/dynamic-layers/meta-python/recipes-connectivity/crda/crda/crda-4.14-python-3.patch
blob: 9125d0ab97c41d9e5f7067bb1360d51650c7dd8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
Imported from Gentoo
https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9c50acec16bc7c33d6dc122c007d713e7fbecf9c

Signed-off-by: Khem Raj <raj.khem@gmail.com>

--- a/utils/key2pub.py
+++ b/utils/key2pub.py
@@ -1,22 +1,22 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 import sys
 try:
        from M2Crypto import RSA
-except ImportError, e:
+except ImportError as 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(output, name, val):
-    while val[0] == '\0':
+    while val[0:1] == b'\0':
         val = val[1:]
     while len(val) % 8:
-        val = '\0' + val
+        val = b'\0' + val
     vnew = []
     while len(val):
-        vnew.append((val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]))
+        vnew.append((val[0:1], val[1:2], val[2:3], val[3:4], val[4:5], val[5:6], val[6:7], val[7:8]))
         val = val[8:]
     vnew.reverse()
     output.write('static BN_ULONG %s[%d] = {\n' % (name, len(vnew)))
@@ -34,13 +34,13 @@ def print_ssl_64(output, name, val):
     output.write('};\n\n')
 
 def print_ssl_32(output, name, val):
-    while val[0] == '\0':
+    while val[0:1] == b'\0':
         val = val[1:]
     while len(val) % 4:
-        val = '\0' + val
+        val = b'\0' + val
     vnew = []
     while len(val):
-        vnew.append((val[0], val[1], val[2], val[3], ))
+        vnew.append((val[0:1], val[1:2], val[2:3], val[3:4]))
         val = val[4:]
     vnew.reverse()
     output.write('static BN_ULONG %s[%d] = {\n' % (name, len(vnew)))
@@ -81,21 +81,21 @@ struct pubkey {
 
 static struct pubkey keys[] __attribute__((unused))= {
 ''')
-    for n in xrange(n + 1):
+    for n in range(n + 1):
         output.write('	KEYS(e_%d, n_%d),\n' % (n, n))
     output.write('};\n')
     pass
 
 def print_gcrypt(output, name, val):
     output.write('#include <stdint.h>\n')
-    while val[0] == '\0':
+    while val[0:1] == b'\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))
+        output.write('0x%.2x, ' % (v if sys.version_info[0] >=3 else ord(v)))
         idx += 1
         if idx == 8:
             idx = 0
@@ -118,7 +118,7 @@ struct key_params {
 
 static const struct key_params keys[] __attribute__((unused))= {
 ''')
-    for n in xrange(n + 1):
+    for n in range(n + 1):
         output.write('	KEYS(e_%d, n_%d),\n' % (n, n))
     output.write('};\n')
     
@@ -136,7 +136,7 @@ except IndexError:
     mode = None
 
 if not mode in modes:
-    print 'Usage: %s [%s] input-file... output-file' % (sys.argv[0], '|'.join(modes.keys()))
+    print('Usage: %s [%s] input-file... output-file' % (sys.argv[0], '|'.join(modes.keys())))
     sys.exit(2)
 
 output = open(outfile, 'w')
@@ -154,3 +154,5 @@ for f in files:
     idx += 1
 
 modes[mode][1](output, idx - 1)
+
+output.close()