sun.security.x509: porting rev/04cda5b7a3c1

Changes to KeyUsageExtension, NetscapeCerTypeExtension and
ReasonFlags as to check as to improve checks of array bounds.

sun.security.provider.certpath.DistributionPointFetcher has a
similar change concerning array bounds, where the opportunity
to improve probably was spotted by the fact that it uses
ReasonFlags.

Since in the classes in sun.security.x509 the logic for toString
changed slightly, tests are added that passed both before and
after the change, as to check that the outcome is the same.

Bug: 29631070
Test: run cts -m CtsLibcoreTestCases
Change-Id: I2a2c10c59509063e648f238f82ac71b4f513cd71
8 files changed