############################################################################
# Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
#
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
############################################################################
# This translates the Keys section of a KASP XML file into a dnssec.policy
# file that can be used by dnssec-keymgr.
############################################################################
import re
############################################################################
# Translate KASP duration values into seconds
############################################################################
class kasptime:
class ktlex:
r'\d+'
return t
"ktime : P periods T times"
p[0] = p[2] + p[4]
"ktime : P T times"
p[0] = p[3]
"ktime : P periods"
p[0] = p[2]
"periods : period"
p[0] = p[1]
"periods : periods period"
p[0] = p[1] + p[2]
"times : time"
p[0] = p[1]
"times : times time"
p[0] = p[1] + p[2]
'''period : NUM Y
| NUM M
| NUM D'''
'''time : NUM H
| NUM M
| NUM S'''
print("Syntax error")
############################################################################
# Load the contents of a KASP XML file as a python dictionary
############################################################################
class kasp():
def _todict(t):
if children:
d = {t.tag:
if t.attrib:
if t.text:
if text:
else:
return d
############################################################################
# Load the contents of a KASP XML file as a python dictionary
############################################################################
if __name__ == "__main__":
from pprint import *
import sys
print("Usage: kasp2policy <filename>")
exit(1)
try:
except:
exit(1)
if not p['@name'] or not p['Keys']: continue
if not first:
print("")
if p['Description']:
d = p['Description'].strip()
print("policy %s {" % p['@name'])
if algnum:
if p['Keys']['TTL']:
if kalg['@length']:
if zalg['@length']:
if ksk['Lifetime']:
if zsk['Lifetime']:
if ksk['Standby']:
if zsk['Standby']:
print("};")