chiark / gitweb /
make-secnet-sites: Handle `pub rsa1' properties specially
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 Dec 2019 16:47:36 +0000 (16:47 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 15 Feb 2020 21:56:52 +0000 (21:56 +0000)
We construct these as a special kind of `rsakey' object, rather than
`pubkey' objects.  This means they will be written out to sites files
the way rsa1 keys are: ie in v1, using `pubkey' rather than `pub' in
sites files and using the rsa-public verb rather than make-public.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
make-secnet-sites

index 81d36791466a3ff70d66204dd492bb0309bf4293..f5795ee85c5684db50cf1b34fe85e8c57db01ea6 100755 (executable)
@@ -447,9 +447,28 @@ class rsakey (pubkey):
                        return ['pubkey', str(self.l), self.e, self.n]
                return pubkey.forsites(self,version,xcopy,fs)
 
+class rsakey_newfmt(rsakey):
+       "An old-style RSA public key in new-style sites format"
+       # This is its own class simply to have its own constructor.
+       def __init__(self,w):
+               self.a=w[1].name()
+               assert(self.a == 'rsa1')
+               self.d=w[2].base91()
+               try:
+                       w_inner=list(map(Tainted,
+                                       ['X-PUB-RSA1'] +
+                                       base91s_decode(self.d)
+                                       .decode('ascii')
+                                       .split(' ')))
+               except UnicodeDecodeError:
+                       complain('rsa1 key in new format has bad base91')
+               #print(repr(w_inner), file=sys.stderr)
+               rsakey.__init__(self,w_inner)
 def somepubkey(w):
        if w[0]=='pubkey':
                return rsakey(w)
+       elif w[0]=='pub' and w[1]=='rsa1':
+               return rsakey_newfmt(w)
        elif w[0]=='pub':
                return pubkey(w)
        else: