首页
社区
课程
招聘
[旧帖] [原创]fllexlm java版的pubkeyVerify 0.00雪花
发表于: 2009-8-27 02:28 2160

[旧帖] [原创]fllexlm java版的pubkeyVerify 0.00雪花

2009-8-27 02:28
2160
public class Signverify
        implements FlexlmConstants
{

        static final String CVSId = "$Id";
        protected static String certicomName;
        protected static final String signatureAlgorithmName = "ECDSA";
        public static boolean pubkeyVerify(byte abyte0[], byte abyte1[], VendorInfo vendorinfo, int i)
                throws FlexlmException
        {
                String s = initCerticom();
                if (s == null)
                        throw new FlexlmException(-103, 1);
                String s1;
                switch (i)
                {
                case 2: // '\002'
                        s1 = "sect113r1";
                        break;

                case 3: // '\003'
                        s1 = "ec163a02";
                        break;

                case 4: // '\004'
                        s1 = "ec239a03";
                        break;

                default:
                        throw new FlexlmException(-103, 2);
                }
                SystemConfig systemconfig = SystemConfig.getConfig();
                systemconfig.setCurve(s1);  //设置ecc曲线
                systemconfig.setConformance(16);
                systemconfig.setPtCompression(2);
                systemconfig.setFormat(10);
                java.security.PublicKey publickey = vendorimsg.getPublicKey(i); //提取公钥
                if (publickey == null)
                        throw new FlexlmException(15, 28);
                byte abyte2[] = publickey.getEncoded();   //L_G译码
                X509EncodedKeySpec x509encodedkeyspec = new X509EncodedKeySpec(abyte2);
                KeyFactory keyfactory;
                        keyfactory = KeyFactory.getInstance("ECDSA");
               
                        java.security.PublicKey publickey1;
                        publickey1 = keyfactory.generatePublic(x509encodedkeyspec); //生成ecc公钥,程序带的是压缩的(Gx,Gy)
               
                        boolean flag;
                        Signature signature = Signature.getInstance("ECDSA", s);
                        signature.initVerify(publickey1);
                        signature.update(abyte0);
                        flag = signature.verify(abyte1); //如果验证通过返回1
                        return flag;
        }

        protected static String initCerticom()
        {
                if (certicomName != null)
                {
                        return certicomName;
                } else
                {
                        Certicom certicom = new Certicom();
                        if (Security.addProvider(certicom) >= 0);
                        certicomName = certicom.getName();
                        return certicomName;
                }
        }

}

[课程]FART 脱壳王!加量不加价!FART作者讲授!

收藏
免费 0
支持
分享
最新回复 (1)
雪    币: 225
活跃值: (15)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
【原创】fllexlm java版的pubkeyVerify


能否告知何处可下载到java版的flexlm?或是大侠能直接传一份到看雪上来,无限感激。
2009-10-25 12:17
0
游客
登录 | 注册 方可回帖
返回
//