chiark / gitweb /
make-secnet-sites: Prepare for multiple public key types
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 9 Nov 2019 00:03:49 +0000 (00:03 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 15 Feb 2020 21:56:52 +0000 (21:56 +0000)
* Introduce a general base typee for public keys.

* Indirect public key object construction through a function
  which is suitable for passing to listof(), and which will
  despatch appropriately.  This allows a heterogenous list.

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

index 0f1e8bab8b7d99fc58788e833841a6d0f33a1286..b7720d2f1ece0a14b0f119fc5a3be73803095b4a 100755 (executable)
@@ -413,7 +413,10 @@ class address (basetype):
        def __str__(self):
                return '"%s"; port %d'%(self.adr,self.port)
 
-class rsakey (basetype):
+class pubkey (basetype):
+       "Some kind of publie key"
+
+class rsakey (pubkey):
        "An RSA public key"
        def __init__(self,w):
                self.l=w[1].number(0,max['rsa_bits'],'rsa len')
@@ -423,6 +426,12 @@ class rsakey (basetype):
        def __str__(self):
                return 'rsa-public("%s","%s")'%(self.e,self.n)
 
+def somepubkey(w):
+       if w[0]=='pubkey':
+               return rsakey(w)
+       else:
+               assert(False)
+
 # Possible properties of configuration nodes
 keywords={
  'contact':(email,"Contact address"),
@@ -435,7 +444,7 @@ keywords={
  'renegotiate-time':(num,"Time after key setup to begin renegotiation (ms)"),
  'restrict-nets':(networks,"Allowable networks"),
  'networks':(networks,"Claimed networks"),
- 'pubkey':(listof(rsakey),"RSA public site key"),
+ 'pubkey':(listof(somepubkey),"RSA public site key"),
  'peer':(single_ipaddr,"Tunnel peer IP address"),
  'address':(address,"External contact address and port"),
  'mobile':(boolean,"Site is mobile"),