refactor IP check in asn1 module