Package java.security

Examples of java.security.PublicKey


        if (SOSKeyGenerator.provider == null) { throw new Exception("Provider is null"); }
        if (SOSKeyGenerator.keyAlgorithmName == null) { throw new Exception(
                "keyAlgorithmName is null"); }
        if (keyFile == null) { throw new Exception("Private Key File is null"); }

        PublicKey pubKey = null;

        try {
            if (SOSKeyGenerator.provider.equalsIgnoreCase("BC")
                    && Security.getProvider("BC") == null) {
                Provider bp = new org.bouncycastle.jce.provider.BouncyCastleProvider();
View Full Code Here


            //Signatur Datei erstellen
            SOSSignature.signToFile(fileToSign, signFile, privKey);

            // Signatur verifizieren
            PublicKey pubKey = SOSKeyGenerator
                    .getPublicKeyFromFile(publicKeyFileName);
            boolean verifies = SOSSignature.verify(fileToSign, signFile, pubKey);

            System.out.println("Signature verifies: " + verifies);
View Full Code Here

  protected static byte[] getSharedSecret(byte[] otherPublicKeyBytes, KeyAgreement agreement) {
    BigInteger otherPublicKeyInt = new BigInteger(1, otherPublicKeyBytes);
    try {
      KeyFactory keyFactory = KeyFactory.getInstance("DH");
      KeySpec otherPublicKeySpec = new DHPublicKeySpec(otherPublicKeyInt, RTMPHandshake.DH_MODULUS, RTMPHandshake.DH_BASE);
      PublicKey otherPublicKey = keyFactory.generatePublic(otherPublicKeySpec);
      agreement.doPhase(otherPublicKey, true);
    } catch (Exception e) {
      JFLog.log("Exception getting the shared secret", e);
    }
    byte[] sharedSecret = agreement.generateSecret();
View Full Code Here

       
        // Set up the Key
        KeyPairGenerator rsaKeygen = KeyPairGenerator.getInstance("RSA");
        KeyPair kp = rsaKeygen.generateKeyPair();
        PrivateKey priv = kp.getPrivate();
        PublicKey pub = kp.getPublic();

        // Generate a traffic key
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
        keygen.init(256);
        SecretKey secretKey = keygen.generateKey();
View Full Code Here

       
        // Set up the Key
        KeyPairGenerator rsaKeygen = KeyPairGenerator.getInstance("RSA");
        KeyPair kp = rsaKeygen.generateKeyPair();
        PrivateKey priv = kp.getPrivate();
        PublicKey pub = kp.getPublic();

        // Generate a traffic key
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
        keygen.init(256);
        SecretKey secretKey = keygen.generateKey();
View Full Code Here

        // Set up the Key
        KeyPairGenerator rsaKeygen = KeyPairGenerator.getInstance("RSA");
        KeyPair kp = rsaKeygen.generateKeyPair();
        PrivateKey priv = kp.getPrivate();
        PublicKey pub = kp.getPublic();

        // Generate a traffic key
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
        keygen.init(256);
        SecretKey secretKey = keygen.generateKey();
View Full Code Here

        }
    }

    @org.junit.Test
    public void testRSAPublicKey() throws Exception {
        PublicKey rsaKeyControl = loadPublicKey("rsa-KeyInfoReference.key", "RSA");

        Document doc = loadXML("KeyInfoReference-RSA.xml");
        markKeyInfoIdAttrs(doc);

        Element referenceElement = doc.getElementById("theReference");
View Full Code Here

    }

    @org.junit.Test
    public void testnewKeyValue() {
        // test newKeyValue(PublicKey pk)
        PublicKey myPubKey = new PublicKey() {
            private static final long serialVersionUID = 2756606866185189114L;
           
                public byte[] getEncoded() {
                    return new byte[20];
                }
View Full Code Here

            // Get CA details
            Certificate caCert = ca.getCertificate();
            request.setAttribute("cert", caCert);
            request.setAttribute("highestSerial", ca.getHighestSerialNumber());
            request.setAttribute("certText", CaUtils.base64Certificate(caCert));
            PublicKey publickey = caCert.getPublicKey();
            String keySize = null;
            if(publickey instanceof RSAPublicKey) {
                keySize = ""+((RSAPublicKey)publickey).getModulus().bitLength();
                request.setAttribute("keySize", keySize);
            }
View Full Code Here

            }
            CertificationAuthority ca = getCertificationAuthority(request);
           
            String certText = ca.getCertificateBase64Text(new BigInteger(sNo.trim()));
            Certificate cert = ca.getCertificate(new BigInteger(sNo.trim()));
            PublicKey publickey = cert.getPublicKey();
            String keySize = null;
            if(publickey instanceof RSAPublicKey) {
                keySize = ""+((RSAPublicKey)publickey).getModulus().bitLength();
            }
            request.setAttribute("sNo", sNo);
View Full Code Here

TOP

Related Classes of java.security.PublicKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.