814 const Type** fields = TypeTuple::fields(argcnt);
815 int argp = TypeFunc::Parms;
816 fields[argp++] = TypePtr::NOTNULL; // src
817 fields[argp++] = TypePtr::NOTNULL; // dest
818 fields[argp++] = TypePtr::NOTNULL; // k array
819 if (Matcher::pass_original_key_for_aes()) {
820 fields[argp++] = TypePtr::NOTNULL; // original k array
821 }
822 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
823 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
824
825 // no result type needed
826 fields = TypeTuple::fields(1);
827 fields[TypeFunc::Parms+0] = NULL; // void
828 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
829 return TypeFunc::make(domain, range);
830 }
831
832 /**
833 * int updateBytesCRC32(int crc, byte* b, int len)
834 */
835 const TypeFunc* OptoRuntime::updateBytesCRC32_Type() {
836 // create input type (domain)
837 int num_args = 3;
838 int argcnt = num_args;
839 const Type** fields = TypeTuple::fields(argcnt);
840 int argp = TypeFunc::Parms;
841 fields[argp++] = TypeInt::INT; // crc
842 fields[argp++] = TypePtr::NOTNULL; // src
843 fields[argp++] = TypeInt::INT; // len
844 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
845 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
846
847 // result type needed
848 fields = TypeTuple::fields(1);
849 fields[TypeFunc::Parms+0] = TypeInt::INT; // crc result
850 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
851 return TypeFunc::make(domain, range);
852 }
853
854 // for cipherBlockChaining calls of aescrypt encrypt/decrypt, four pointers and a length, returning int
855 const TypeFunc* OptoRuntime::cipherBlockChaining_aescrypt_Type() {
856 // create input type (domain)
857 int num_args = 5;
858 if (Matcher::pass_original_key_for_aes()) {
859 num_args = 6;
860 }
861 int argcnt = num_args;
862 const Type** fields = TypeTuple::fields(argcnt);
863 int argp = TypeFunc::Parms;
864 fields[argp++] = TypePtr::NOTNULL; // src
865 fields[argp++] = TypePtr::NOTNULL; // dest
866 fields[argp++] = TypePtr::NOTNULL; // k array
867 fields[argp++] = TypePtr::NOTNULL; // r array
868 fields[argp++] = TypeInt::INT; // src len
869 if (Matcher::pass_original_key_for_aes()) {
870 fields[argp++] = TypePtr::NOTNULL; // original k array
871 }
872 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
873 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
874
875 // returning cipher len (int)
876 fields = TypeTuple::fields(1);
877 fields[TypeFunc::Parms+0] = TypeInt::INT;
878 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
879 return TypeFunc::make(domain, range);
880 }
881
882 /*
883 * void implCompress(byte[] buf, int ofs)
884 */
885 const TypeFunc* OptoRuntime::sha_implCompress_Type() {
886 // create input type (domain)
887 int num_args = 2;
888 int argcnt = num_args;
889 const Type** fields = TypeTuple::fields(argcnt);
890 int argp = TypeFunc::Parms;
891 fields[argp++] = TypePtr::NOTNULL; // buf
892 fields[argp++] = TypePtr::NOTNULL; // state
893 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
894 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
895
896 // no result type needed
897 fields = TypeTuple::fields(1);
898 fields[TypeFunc::Parms+0] = NULL; // void
899 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
900 return TypeFunc::make(domain, range);
901 }
902
903 /*
904 * int implCompressMultiBlock(byte[] b, int ofs, int limit)
905 */
906 const TypeFunc* OptoRuntime::digestBase_implCompressMB_Type() {
907 // create input type (domain)
908 int num_args = 4;
909 int argcnt = num_args;
910 const Type** fields = TypeTuple::fields(argcnt);
911 int argp = TypeFunc::Parms;
912 fields[argp++] = TypePtr::NOTNULL; // buf
913 fields[argp++] = TypePtr::NOTNULL; // state
914 fields[argp++] = TypeInt::INT; // ofs
915 fields[argp++] = TypeInt::INT; // limit
916 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
917 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
918
919 // returning ofs (int)
920 fields = TypeTuple::fields(1);
921 fields[TypeFunc::Parms+0] = TypeInt::INT; // ofs
922 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
923 return TypeFunc::make(domain, range);
924 }
925
926 const TypeFunc* OptoRuntime::multiplyToLen_Type() {
927 // create input type (domain)
928 int num_args = 6;
929 int argcnt = num_args;
930 const Type** fields = TypeTuple::fields(argcnt);
931 int argp = TypeFunc::Parms;
932 fields[argp++] = TypePtr::NOTNULL; // x
933 fields[argp++] = TypeInt::INT; // xlen
934 fields[argp++] = TypePtr::NOTNULL; // y
935 fields[argp++] = TypeInt::INT; // ylen
936 fields[argp++] = TypePtr::NOTNULL; // z
937 fields[argp++] = TypeInt::INT; // zlen
938 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
939 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
940
941 // no result type needed
942 fields = TypeTuple::fields(1);
943 fields[TypeFunc::Parms+0] = NULL;
944 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
945 return TypeFunc::make(domain, range);
946 }
947
948 const TypeFunc* OptoRuntime::squareToLen_Type() {
949 // create input type (domain)
950 int num_args = 4;
951 int argcnt = num_args;
952 const Type** fields = TypeTuple::fields(argcnt);
953 int argp = TypeFunc::Parms;
954 fields[argp++] = TypePtr::NOTNULL; // x
955 fields[argp++] = TypeInt::INT; // len
956 fields[argp++] = TypePtr::NOTNULL; // z
957 fields[argp++] = TypeInt::INT; // zlen
|
814 const Type** fields = TypeTuple::fields(argcnt);
815 int argp = TypeFunc::Parms;
816 fields[argp++] = TypePtr::NOTNULL; // src
817 fields[argp++] = TypePtr::NOTNULL; // dest
818 fields[argp++] = TypePtr::NOTNULL; // k array
819 if (Matcher::pass_original_key_for_aes()) {
820 fields[argp++] = TypePtr::NOTNULL; // original k array
821 }
822 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
823 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
824
825 // no result type needed
826 fields = TypeTuple::fields(1);
827 fields[TypeFunc::Parms+0] = NULL; // void
828 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
829 return TypeFunc::make(domain, range);
830 }
831
832 /**
833 * int updateBytesCRC32(int crc, byte* b, int len)
834 *
835 * If CCallingConventionRequiresIntsAsLongs is true, the platform ABI
836 * requires us to expand int arguments to long. The TypeTuple of an
837 * original int argument then consists of a TypeLong::LONG and a
838 * TypeLONG::HALF pair.
839 */
840 const TypeFunc* OptoRuntime::updateBytesCRC32_Type() {
841 // create input type (domain)
842 int num_args = CCallingConventionRequiresIntsAsLongs ? 5 : 3;
843 int argcnt = num_args;
844 int argp = TypeFunc::Parms;
845 const Type** fields = TypeTuple::fields(argcnt);
846 if (CCallingConventionRequiresIntsAsLongs) {
847 fields[argp++] = TypeLong::LONG; // crc
848 fields[argp++] = TypeLong::HALF; // placeholder
849 fields[argp++] = TypePtr::NOTNULL; // src
850 fields[argp++] = TypeLong::LONG; // len
851 fields[argp++] = TypeLong::HALF; // placeholder
852 } else {
853 fields[argp++] = TypeInt::INT; // crc
854 fields[argp++] = TypePtr::NOTNULL; // src
855 fields[argp++] = TypeInt::INT; // len
856 }
857 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
858 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
859
860 // result type needed
861 fields = TypeTuple::fields(1);
862 fields[TypeFunc::Parms+0] = TypeInt::INT; // crc result
863 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
864 return TypeFunc::make(domain, range);
865 }
866
867 /*
868 * For cipherBlockChaining calls of aescrypt encrypt/decrypt, four pointers and a length, returning int.
869 *
870 * If CCallingConventionRequiresIntsAsLongs is true, the platform ABI
871 * requires us to expand int arguments to long. The TypeTuple of an
872 * original int argument then consists of a TypeLong::LONG and a
873 * TypeLONG::HALF pair.
874 */
875 const TypeFunc* OptoRuntime::cipherBlockChaining_aescrypt_Type() {
876 // create input type (domain)
877 int num_args = CCallingConventionRequiresIntsAsLongs ? 6 : 5;
878 if (Matcher::pass_original_key_for_aes()) {
879 num_args += 1;
880 }
881 int argcnt = num_args;
882 int argp = TypeFunc::Parms;
883 const Type** fields = TypeTuple::fields(argcnt);
884 fields[argp++] = TypePtr::NOTNULL; // src
885 fields[argp++] = TypePtr::NOTNULL; // dest
886 fields[argp++] = TypePtr::NOTNULL; // k array
887 fields[argp++] = TypePtr::NOTNULL; // r array
888 if (CCallingConventionRequiresIntsAsLongs) {
889 fields[argp++] = TypeLong::LONG; // src len
890 fields[argp++] = TypeLong::HALF; // placeholder
891 } else {
892 fields[argp++] = TypeInt::INT; // src len
893 }
894 if (Matcher::pass_original_key_for_aes()) {
895 fields[argp++] = TypePtr::NOTNULL; // original k array
896 }
897 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
898 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
899
900 // returning cipher len (int)
901 fields = TypeTuple::fields(1);
902 fields[TypeFunc::Parms+0] = TypeInt::INT;
903 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
904 return TypeFunc::make(domain, range);
905 }
906
907 /*
908 * void implCompress(byte[] buf, int ofs)
909 */
910 const TypeFunc* OptoRuntime::sha_implCompress_Type() {
911 // create input type (domain)
912 int num_args = 2;
913 int argcnt = num_args;
914 const Type** fields = TypeTuple::fields(argcnt);
915 int argp = TypeFunc::Parms;
916 fields[argp++] = TypePtr::NOTNULL; // buf
917 fields[argp++] = TypePtr::NOTNULL; // state
918 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
919 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
920
921 // no result type needed
922 fields = TypeTuple::fields(1);
923 fields[TypeFunc::Parms+0] = NULL; // void
924 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
925 return TypeFunc::make(domain, range);
926 }
927
928 /*
929 * int implCompressMultiBlock(byte[] b, int ofs, int limit)
930 *
931 * If CCallingConventionRequiresIntsAsLongs is true, the platform ABI
932 * requires us to expand int arguments to long. The TypeTuple of an
933 * original int argument then consists of a TypeLong::LONG and a
934 * TypeLONG::HALF pair.
935 */
936 const TypeFunc* OptoRuntime::digestBase_implCompressMB_Type() {
937 // create input type (domain)
938 int num_args = CCallingConventionRequiresIntsAsLongs ? 6 : 4;
939 int argcnt = num_args;
940 int argp = TypeFunc::Parms;
941 const Type** fields = TypeTuple::fields(argcnt);
942 fields[argp++] = TypePtr::NOTNULL; // buf
943 fields[argp++] = TypePtr::NOTNULL; // state
944 if (CCallingConventionRequiresIntsAsLongs) {
945 fields[argp++] = TypeLong::LONG; // ofs
946 fields[argp++] = TypeLong::HALF; // placeholder
947 fields[argp++] = TypeLong::LONG; // limit
948 fields[argp++] = TypeLong::HALF; // placeholder
949 } else {
950 fields[argp++] = TypeInt::INT; // ofs
951 fields[argp++] = TypeInt::INT; // limit
952 }
953 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
954 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
955
956 // returning ofs (int)
957 fields = TypeTuple::fields(1);
958 fields[TypeFunc::Parms+0] = TypeInt::INT; // ofs
959 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
960 return TypeFunc::make(domain, range);
961 }
962
963 /*
964 * If CCallingConventionRequiresIntsAsLongs is true, the platform ABI
965 * requires us to expand int arguments to long. The TypeTuple of an
966 * original int argument then consists of a TypeLong::LONG and a
967 * TypeLONG::HALF pair.
968 */
969 const TypeFunc* OptoRuntime::multiplyToLen_Type() {
970 // create input type (domain)
971 int num_args = CCallingConventionRequiresIntsAsLongs ? 9 : 6;
972 int argcnt = num_args;
973 int argp = TypeFunc::Parms;
974 const Type** fields = TypeTuple::fields(argcnt);
975 if (CCallingConventionRequiresIntsAsLongs) {
976 fields[argp++] = TypePtr::NOTNULL; // x
977 fields[argp++] = TypeLong::LONG; // xlen
978 fields[argp++] = TypeLong::HALF; // placeholder
979 fields[argp++] = TypePtr::NOTNULL; // y
980 fields[argp++] = TypeLong::LONG; // ylen
981 fields[argp++] = TypeLong::HALF; // placeholder
982 fields[argp++] = TypePtr::NOTNULL; // z
983 fields[argp++] = TypeLong::LONG; // zlen
984 fields[argp++] = TypeLong::HALF; // placeholder
985 } else {
986 fields[argp++] = TypePtr::NOTNULL; // x
987 fields[argp++] = TypeInt::INT; // xlen
988 fields[argp++] = TypePtr::NOTNULL; // y
989 fields[argp++] = TypeInt::INT; // ylen
990 fields[argp++] = TypePtr::NOTNULL; // z
991 fields[argp++] = TypeInt::INT; // zlen
992 }
993 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
994 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
995
996 // no result type needed
997 fields = TypeTuple::fields(1);
998 fields[TypeFunc::Parms+0] = NULL;
999 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1000 return TypeFunc::make(domain, range);
1001 }
1002
1003 const TypeFunc* OptoRuntime::squareToLen_Type() {
1004 // create input type (domain)
1005 int num_args = 4;
1006 int argcnt = num_args;
1007 const Type** fields = TypeTuple::fields(argcnt);
1008 int argp = TypeFunc::Parms;
1009 fields[argp++] = TypePtr::NOTNULL; // x
1010 fields[argp++] = TypeInt::INT; // len
1011 fields[argp++] = TypePtr::NOTNULL; // z
1012 fields[argp++] = TypeInt::INT; // zlen
|