コード例 #1
0
ファイル: test_signer.py プロジェクト: sanjeevr93/PyNDNABS
    def setUp(self):
        db = ndnabs.PickleDb('%s/test_authority.db' % os.path.dirname(os.path.realpath(__file__)))
        self.aa = ndnabs.AttributeAuthority(db)

        fd, self.tmpDbPath = tempfile.mkstemp()
        os.close(fd)
        shutil.copy('%s/test_signer.db' % os.path.dirname(os.path.realpath(__file__)), self.tmpDbPath)
        print (self.tmpDbPath)

        db = ndnabs.PickleDb(self.tmpDbPath)
        self.signer = ndnabs.Signer(db)
        self.signer.install_public_params(self.aa.get_public_params())
コード例 #2
0
    def __init__(self, absPath, maxAttributes):
        self.keyChain = KeyChain("pib-memory:", "tpm-memory:")
        self.keyChain.createIdentityV2("/test/identity")
        self.validator = Validator(
            ValidationPolicyFromPib(self.keyChain.getPib()))
        # , filename, groupSize, nAttributes, absPath, keepData = False):

        # sys.stderr.write ("Using NDN-ABS authority, signer, and verifier database from %s\n" % absPath)
        self.db = ndnabs.PickleDb(absPath)

        self.signer = ndnabs.Signer(self.db)
        self.verifier = ndnabs.Verifier(self.db)

        try:
            info = self.signer.get_public_params_info()
            if info.getName().getPrefix(
                    -2).toUri() != "/icn2019/test/authority":
                raise RuntimeError(
                    'NDN-ABS authority exists, but not setup for experiment. Use `ndnabs setup -f /icn2019/test/authority` to force-setup the authority'
                )
        except:
            raise RuntimeError(
                "Public parameters are not properly installed for the signer/verifier"
            )

        maxAttributes = [
            b'attribute%d' % i for i in range(1, maxAttributes + 1)
        ]

        for attr in maxAttributes:
            if not attr in self.signer.get_attributes():
                raise RuntimeError(
                    "%s attribute missing. Generate attributes for the experiment using `ndnabs gen-secret %s | ndnabs install-secret`"
                    % (str(attr, 'utf-8'), ' '.join(
                        [str(i, 'utf-8') for i in maxAttributes])))
コード例 #3
0
 def test_setup(self):
     fd, tmpDbPath = tempfile.mkstemp()
     os.close(fd)
     os.remove(tmpDbPath)
     print(tmpDbPath)
     db = ndnabs.PickleDb(tmpDbPath)
     self.aa = ndnabs.AttributeAuthority(db)
     self.aa.setup(pyndn.Name("/test/name"))
コード例 #4
0
 def setUp(self):
     db = ndnabs.PickleDb('%s/test_authority.db' %
                          os.path.dirname(os.path.realpath(__file__)))
     self.aa = ndnabs.AttributeAuthority(db)