diff --git a/scapy/layers/ipsec.py b/scapy/layers/ipsec.py index b609b9473c81424bba202a26a473982ca6bb5d09..6138e896925f7449ff5d5367736f8b28037bf96e 100644 --- a/scapy/layers/ipsec.py +++ b/scapy/layers/ipsec.py @@ -41,7 +41,22 @@ True import socket import struct -from Crypto.Util.number import GCD as gcd +try: + from Crypto.Util.number import GCD as gcd +except ImportError: + try: + from fractions import gcd + except ImportError: + def gcd(a, b): + """Fallback implementation when Crypto is missing, and fractions does + not exist (Python 2.5) + + """ + if b > a: + a, b = b, a + c = a % b + return b if c == 0 else gcd(c, b) + from scapy.data import IP_PROTOS