Ejemplo n.º 1
0
 def hashPassphrase(self, authProtocol, privKey):
     if authProtocol == hmacmd5.HmacMd5.serviceID:
         hashAlgo = md5
     elif authProtocol == hmacsha.HmacSha.serviceID:
         hashAlgo = sha1
     elif authProtocol in hmacsha2.HmacSha2.hashAlgorithms:
         hashAlgo = hmacsha2.HmacSha2.hashAlgorithms[authProtocol]
     else:
         raise error.ProtocolError('Unknown auth protocol %s' %
                                   (authProtocol, ))
     return localkey.hashPassphrase(privKey, hashAlgo)
Ejemplo n.º 2
0
    def hashPassphrase(self, authProtocol, privKey):
        if authProtocol == hmacmd5.HmacMd5.SERVICE_ID:
            hashAlgo = md5

        elif authProtocol == hmacsha.HmacSha.SERVICE_ID:
            hashAlgo = sha1

        elif authProtocol in hmacsha2.HmacSha2.HASH_ALGORITHM:
            hashAlgo = hmacsha2.HmacSha2.HASH_ALGORITHM[authProtocol]

        else:
            raise error.ProtocolError('Unknown auth protocol %s' %
                                      (authProtocol, ))

        return localkey.hashPassphrase(privKey, hashAlgo)
Ejemplo n.º 3
0
    def hashPassphrase(self, authProtocol, privKey):
        if authProtocol == hmacmd5.HmacMd5.SERVICE_ID:
            hashAlgo = md5

        elif authProtocol == hmacsha.HmacSha.SERVICE_ID:
            hashAlgo = sha1

        elif authProtocol in hmacsha2.HmacSha2.HASH_ALGORITHM:
            hashAlgo = hmacsha2.HmacSha2.HASH_ALGORITHM[authProtocol]

        else:
            raise error.ProtocolError(
                'Unknown auth protocol %s' % (authProtocol,))

        return localkey.hashPassphrase(privKey, hashAlgo)
Ejemplo n.º 4
0
 def localizeKey(self, authProtocol, privKey, snmpEngineID):
     if authProtocol == hmacmd5.HmacMd5.serviceID:
         hashAlgo = md5
     elif authProtocol == hmacsha.HmacSha.serviceID:
         hashAlgo = sha1
     elif authProtocol in hmacsha2.HmacSha2.hashAlgorithms:
         hashAlgo = hmacsha2.HmacSha2.hashAlgorithms[authProtocol]
     else:
         raise error.ProtocolError('Unknown auth protocol %s' %
                                   (authProtocol, ))
     localPrivKey = localkey.localizeKey(privKey, snmpEngineID, hashAlgo)
     # now extend this key if too short by repeating steps that includes the hashPassphrase step
     while len(localPrivKey) < self.keySize:
         # this is the difference between reeder and bluementhal
         newKey = localkey.hashPassphrase(localPrivKey, hashAlgo)
         localPrivKey += localkey.localizeKey(newKey, snmpEngineID,
                                              hashAlgo)
     return localPrivKey[:self.keySize]
Ejemplo n.º 5
0
    def localizeKey(self, authProtocol, privKey, snmpEngineID):
        if authProtocol == hmacmd5.HmacMd5.SERVICE_ID:
            hashAlgo = md5

        elif authProtocol == hmacsha.HmacSha.SERVICE_ID:
            hashAlgo = sha1

        elif authProtocol in hmacsha2.HmacSha2.HASH_ALGORITHM:
            hashAlgo = hmacsha2.HmacSha2.HASH_ALGORITHM[authProtocol]

        else:
            raise error.ProtocolError(
                'Unknown auth protocol %s' % (authProtocol,))

        localPrivKey = localkey.localizeKey(privKey, snmpEngineID, hashAlgo)

        # now extend this key if too short by repeating steps that includes the hashPassphrase step
        while len(localPrivKey) < self.KEY_SIZE:
            # this is the difference between reeder and bluementhal
            newKey = localkey.hashPassphrase(localPrivKey, hashAlgo)
            localPrivKey += localkey.localizeKey(newKey, snmpEngineID, hashAlgo)

        return localPrivKey[:self.KEY_SIZE]
Ejemplo n.º 6
0
 def hashPassphrase(self, authKey):
     return localkey.hashPassphrase(authKey, self._hashAlgo)
Ejemplo n.º 7
0
 def hashPassphrase(self, authKey):
     return localkey.hashPassphrase(authKey, self._hashAlgo)