1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package libcore.math; 18 19 /** 20 * @hide 21 */ 22 public final class NativeBN { 23 BN_new()24 public static native long BN_new(); 25 // BIGNUM *BN_new(void); 26 BN_free(long a)27 public static native void BN_free(long a); 28 // void BN_free(BIGNUM *a); 29 litEndInts2bn(int[] ints, int len, boolean neg, long ret)30 public static native void litEndInts2bn(int[] ints, int len, boolean neg, long ret); 31 32 // Generates a minimal length representation of |a| in a sequence of integers, least-significant 33 // word at index 0. bn2litEndInts(long a)34 public static native int[] bn2litEndInts(long a); 35 BN_mul(long r, long a, long b)36 public static native void BN_mul(long r, long a, long b); 37 // int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); 38 BN_div(long dv, long rem, long num, long divisor)39 public static native void BN_div(long dv, long rem, long num, long divisor); 40 // int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *num, const BIGNUM *divisor, BN_CTX *ctx); 41 BN_mod_exp(long r, long a, long p, long m)42 public static native void BN_mod_exp(long r, long a, long p, long m); 43 // int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx); 44 } 45