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)
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)
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)
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]
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]
def hashPassphrase(self, authKey): return localkey.hashPassphrase(authKey, self._hashAlgo)
def hashPassphrase(self, authKey): return localkey.hashPassphrase(authKey, self._hashAlgo)