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 rounds = int(ceil(self.KEY_SIZE * 1.0 / len(localPrivKey))) for _ in range(1, rounds): localPrivKey += localPrivKey.clone( hashAlgo(localPrivKey.asOctets()).digest()) return localPrivKey[:self.KEY_SIZE]
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.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) 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 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) return localPrivKey[:self.KEY_SIZE]
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) return localPrivKey[:self.KEY_SIZE]
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 for count in range(1, int(ceil(self.keySize * 1.0 / len(localPrivKey)))): localPrivKey += hashAlgo(localPrivKey).digest() return localPrivKey[:self.keySize]
def localizeKey(self, authKey, snmpEngineID): return localkey.localizeKey(authKey, snmpEngineID, self._hashAlgo)
def localizeKey(self, authKey, snmpEngineID): return localkey.localizeKey(authKey, snmpEngineID, self._hashAlgo)