added handling of nonce=null and counter.length=0