Пример #1
0
    def setUp(self):
        testCertDirectory = 'policy_config/certs'
        self.testCertFile = os.path.join(testCertDirectory, 'test.cert')

        self.pibImpl = PibMemory()
        self.tpmBackEnd = TpmBackEndMemory()
        self.policyManager = ConfigPolicyManager(
            'policy_config/simple_rules.conf', CertificateCacheV2())

        self.identityName = Name('/TestConfigPolicyManager/temp')
        # to match the anchor cert
        self.keyName = Name(
            self.identityName).append("KEY").append("ksk-1416010123")
        self.pibImpl.addKey(self.identityName, self.keyName,
                            TEST_RSA_PUBLIC_KEY_DER)
        # Set the password to None since we have an unencrypted PKCS #8 private key.
        self.tpmBackEnd.importKey(self.keyName, TEST_RSA_PRIVATE_KEY_PKCS8,
                                  None)

        self.keyChain = KeyChain(self.pibImpl, self.tpmBackEnd,
                                 self.policyManager)

        pibKey = self.keyChain.getPib().getIdentity(self.identityName).getKey(
            self.keyName)
        # selfSign adds to the PIB.
        self.keyChain.selfSign(pibKey)
Пример #2
0
    def __init__(self,
                 configFileName=None,
                 certificateCache=None,
                 searchDepth=5,
                 graceInterval=3000,
                 keyTimestampTtl=3600000,
                 maxTrackedKeys=1000):
        super(ConfigPolicyManager, self).__init__()

        if certificateCache is None:
            certificateCache = CertificateCache()

        # _certificateCacheV2 will be replaced below, but set it here to make pylint happy.
        self._certificateCacheV2 = CertificateCacheV2()
        if isinstance(certificateCache, CertificateCache):
            self._isSecurityV1 = True
            self._certificateCache = certificateCache
            self._certificateCacheV2 = None
        else:
            self._isSecurityV1 = False
            self._certificateCache = None
            self._certificateCacheV2 = certificateCache

        self._maxDepth = searchDepth
        self._keyGraceInterval = graceInterval
        self._keyTimestampTtl = keyTimestampTtl
        self._maxTrackedKeys = maxTrackedKeys

        self.reset()

        if configFileName != None and configFileName != "":
            self.load(configFileName)
Пример #3
0
    def __init__(self, isSecurityV1):
        self._isSecurityV1 = isSecurityV1

        self._certificateCache = CertificateCache()
        self._certificateCacheV2 = CertificateCacheV2()
        # maps the directory name to certificate names so they can be
        # deleted when necessary
        self._refreshDirectories = {}
Пример #4
0
 def __init__(self):
     self._trustAnchors = TrustAnchorContainer()
     self._verifiedCertificateCache = CertificateCacheV2(3600 * 1000.0)
     self._unverifiedCertificateCache = CertificateCacheV2(300 * 1000.0)