multiplication in GF(p)
<p>I am developing software in JavaCard to addition points in ECC.
the issue is I need some basis operations, so for the moment, I need multiplication and inversion, I already  have addition and subtraction.</p>

<p>I was trying to develop montgomery multiplication but it is for GF(2^m) (I think). </p>

<p>so my example is:</p>

<pre><code>public static void multiplicationGF_p2(){
        byte A = (byte) 7;
        byte p = (byte) 5;
        byte B = (byte) 2;
        byte C = (byte) 0;
        byte n = (byte)8;
        byte i =  (byte)(n - 1);
        for(; i &gt;= 0; i--){
            C = (byte)(((C &amp; 0xFF) + (C &amp; 0xFF) ) + ((A &amp; 0xff) &lt;&lt; getBytePos(B,i)));
            if((C &amp; 0xFF) &gt;= (byte)(p &amp; 0xFF)){
                C = (byte) ((C &amp; 0xFF)-(p &amp; 0xFF));
            }
            if((C &amp; 0xFF) &gt;= (byte)(p &amp; 0xFF)){
                C = (byte) ((C &amp; 0xFF)-(p &amp; 0xFF));
            }
        }
    }
</code></pre>

<p></p>

<p>for example A = 2, B =3, p= 3 C must be 0, C = A. B (mode p)
but this example A = 7, B=2, p=5 , C must be 4, but I have 49.</p>

<p>can someone help me with that?</p>

<p>more methods:</p>

<pre><code>public static byte getBytePos(byte b, byte pos){
        return (byte)(((b &amp; 0xff) &gt;&gt; pos) &amp; 1);
}
</code></pre>

<p>I am trying to be simple, for the moment, but the idea is make multiplication of very big number like arrays[10] of bytes</p>