instead of pop, five more if None checks for the other values (you have already checked bitlength and expiration) .. but pop is more concise.