533 }
534
535 public static boolean isIntrinsicName(GraalHotSpotVMConfig config, String className, String name) {
536 for (VMIntrinsicMethod intrinsic : config.getStore().getIntrinsics()) {
537 if (className.equals(intrinsic.declaringClass)) {
538 if (name.equals(intrinsic.name)) {
539 return true;
540 }
541 }
542 }
543 return false;
544 }
545
546 private static void registerAESPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, Replacements replacements) {
547 if (config.useAESIntrinsics) {
548 assert config.aescryptEncryptBlockStub != 0L;
549 assert config.aescryptDecryptBlockStub != 0L;
550 assert config.cipherBlockChainingEncryptAESCryptStub != 0L;
551 assert config.cipherBlockChainingDecryptAESCryptStub != 0L;
552 String arch = config.osArch;
553 String decryptSuffix = arch.equals("sparc") ? "WithOriginalKey" : "";
554
555 Registration r = new Registration(plugins, "com.sun.crypto.provider.CipherBlockChaining", replacements);
556
557 Pair<String, String> cbcEncryptName = selectIntrinsicName(config, "com/sun/crypto/provider/CipherBlockChaining", "implEncrypt", "encrypt");
558 registerAndCheckMismatch(r, CipherBlockChainingSubstitutions.class, cbcEncryptName, Receiver.class, byte[].class, int.class, int.class,
559 byte[].class, int.class);
560
561 Pair<String, String> cbcDecryptName = selectIntrinsicName(config, "com/sun/crypto/provider/CipherBlockChaining", "implDecrypt", "decrypt");
562 registerAndCheckMismatch(r, CipherBlockChainingSubstitutions.class, cbcDecryptName, cbcDecryptName.getLeft() + decryptSuffix, Receiver.class, byte[].class, int.class, int.class,
563 byte[].class, int.class);
564
565 r = new Registration(plugins, "com.sun.crypto.provider.AESCrypt", replacements);
566
567 Pair<String, String> aesEncryptName = selectIntrinsicName(config, "com/sun/crypto/provider/AESCrypt", "implEncryptBlock", "encryptBlock");
568 registerAndCheckMismatch(r, AESCryptSubstitutions.class, aesEncryptName, Receiver.class, byte[].class, int.class, byte[].class, int.class);
569
570 Pair<String, String> aesDecryptName = selectIntrinsicName(config, "com/sun/crypto/provider/AESCrypt", "implDecryptBlock", "decryptBlock");
571 registerAndCheckMismatch(r, AESCryptSubstitutions.class, aesDecryptName, aesDecryptName.getLeft() + decryptSuffix, Receiver.class, byte[].class, int.class, byte[].class, int.class);
572 }
573 }
|
533 }
534
535 public static boolean isIntrinsicName(GraalHotSpotVMConfig config, String className, String name) {
536 for (VMIntrinsicMethod intrinsic : config.getStore().getIntrinsics()) {
537 if (className.equals(intrinsic.declaringClass)) {
538 if (name.equals(intrinsic.name)) {
539 return true;
540 }
541 }
542 }
543 return false;
544 }
545
546 private static void registerAESPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, Replacements replacements) {
547 if (config.useAESIntrinsics) {
548 assert config.aescryptEncryptBlockStub != 0L;
549 assert config.aescryptDecryptBlockStub != 0L;
550 assert config.cipherBlockChainingEncryptAESCryptStub != 0L;
551 assert config.cipherBlockChainingDecryptAESCryptStub != 0L;
552 String arch = config.osArch;
553 String decryptSuffix = "";
554
555 Registration r = new Registration(plugins, "com.sun.crypto.provider.CipherBlockChaining", replacements);
556
557 Pair<String, String> cbcEncryptName = selectIntrinsicName(config, "com/sun/crypto/provider/CipherBlockChaining", "implEncrypt", "encrypt");
558 registerAndCheckMismatch(r, CipherBlockChainingSubstitutions.class, cbcEncryptName, Receiver.class, byte[].class, int.class, int.class,
559 byte[].class, int.class);
560
561 Pair<String, String> cbcDecryptName = selectIntrinsicName(config, "com/sun/crypto/provider/CipherBlockChaining", "implDecrypt", "decrypt");
562 registerAndCheckMismatch(r, CipherBlockChainingSubstitutions.class, cbcDecryptName, cbcDecryptName.getLeft() + decryptSuffix, Receiver.class, byte[].class, int.class, int.class,
563 byte[].class, int.class);
564
565 r = new Registration(plugins, "com.sun.crypto.provider.AESCrypt", replacements);
566
567 Pair<String, String> aesEncryptName = selectIntrinsicName(config, "com/sun/crypto/provider/AESCrypt", "implEncryptBlock", "encryptBlock");
568 registerAndCheckMismatch(r, AESCryptSubstitutions.class, aesEncryptName, Receiver.class, byte[].class, int.class, byte[].class, int.class);
569
570 Pair<String, String> aesDecryptName = selectIntrinsicName(config, "com/sun/crypto/provider/AESCrypt", "implDecryptBlock", "decryptBlock");
571 registerAndCheckMismatch(r, AESCryptSubstitutions.class, aesDecryptName, aesDecryptName.getLeft() + decryptSuffix, Receiver.class, byte[].class, int.class, byte[].class, int.class);
572 }
573 }
|