second Rivest implementation, debugging