chiark / gitweb /
make-secnet-sites: Write rsa1 keys as `pub rsa1 ...' in >=v2
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 Dec 2019 18:45:44 +0000 (18:45 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 15 Feb 2020 21:56:52 +0000 (21:56 +0000)
This effectively deprecates the `pubkey' keyword, relegating it to a
compatibility feature.

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

index 2e07cf81d769734a6bd4babaadea470f86a0f3de..81d36791466a3ff70d66204dd492bb0309bf4293 100755 (executable)
@@ -431,12 +431,21 @@ class rsakey (pubkey):
                self.e=w[2].bignum_10('rsa','rsa e')
                self.n=w[3].bignum_10('rsa','rsa n')
                if len(w) >= 5: w[4].email()
+               self.a='rsa1'
+               self.d=base91s_encode(b'%d %s %s' %
+                                     (self.l,
+                                      self.e.encode('ascii'),
+                                      self.n.encode('ascii')))
+               # ^ this allows us to use the pubkey.forsites()
+               # method for output in versions>=2
        def __str__(self):
                return 'rsa-public("%s","%s")'%(self.e,self.n)
                # this specialisation means we can generate files
                # compatible with old secnet executables
        def forsites(self,version,xcopy,fs):
-               return ['pubkey', str(self.l), self.e, self.n]
+               if version < 2:
+                       return ['pubkey', str(self.l), self.e, self.n]
+               return pubkey.forsites(self,version,xcopy,fs)
 
 def somepubkey(w):
        if w[0]=='pubkey':