1 package com.quadcap.crypto; 2 3 40 41 import java.util.Random ; 42 import java.math.BigInteger ; 43 import java.nio.ByteBuffer ; 44 45 import com.quadcap.util.text.Text; 46 47 52 public class RSAPublicKey extends RSAKey implements PublicKey { 53 56 public RSAPublicKey() {} 57 58 61 public void init(String rep) { 62 String [] s = Text.extractN(rep, "*:*:*"); 63 super.init(s[3], Integer.parseInt(s[1]), new BigInteger (s[2])); 64 } 65 66 69 public String toString() { 70 return "RSAPub:" + size + ":" + n + ":" + text; 71 } 72 73 76 public String getText() { 77 return text; 78 } 79 80 83 public void f(ByteBuffer plain, ByteBuffer encrypted) { 84 engine(plain, encrypted); 85 } 86 87 90 public BigInteger engine(BigInteger m) { 91 return m.modPow(e, n); 92 } 93 } 94 | Popular Tags |