static byte [ ] generateDSDigest ( DNSKEYRecord key , int digestid ) { MessageDigest digest ; try { switch ( digestid ) { case DSRecord . Digest . SHA1 : digest = MessageDigest . getInstance ( "sha-1" ) ; break ; case DSRecord . Digest . SHA256 : digest = MessageDigest . getInstance ( "sha-256" ) ; break ; case DSRecord . Digest . GOST3411 : digest = MessageDigest . getInstance ( "GOST3411" ) ; break ; case DSRecord . Digest . SHA384 : digest = MessageDigest . getInstance ( "sha-384" ) ; break ; default : throw new IllegalArgumentException ( "unknown DS digest type " + digestid ) ; } } catch ( NoSuchAlgorithmException e ) { throw new IllegalStateException ( "no message digest support" ) ; } digest . update ( key . getName ( ) . toWireCanonical ( ) ) ; digest . update ( key . rdataToWireCanonical ( ) ) ; return digest . digest ( ) ; }
Generate the digest value for a DS key