Package java.security

Examples of java.security.PublicKey


    OpaqueMachine machine = new OpaqueMachine(NetworkPoint.forPublicHostname(rawTarget.host));
    SshKey serviceSshKey = service.getSshKey();
    OpsTarget target = machine.getTarget(serviceSshKey);

    // TODO: We have a bootstrapping problem here!!
    PublicKey sshPublicKey = service.getSshKey().getKeyPair().getPublic();
    SshAuthorizedKey.ensureSshAuthorization(target, "root", sshPublicKey);
  }
View Full Code Here


    }

    @Test
    public void testSchmizzEntry()
            throws UnknownHostException, GeneralSecurityException {
        final PublicKey key = KeyUtil
                .newRSAPublicKey(
                        "e8ff4797075a861db9d2319960a836b2746ada3da514955d2921f2c6a6c9895cbd557f604e43772b6303e3cab2ad82d83b21acdef4edb72524f9c2bef893335115acacfe2989bcbb2e978e4fedc8abc090363e205d975c1fdc35e55ba4daa4b5d5ab7a22c40f547a4a0fd1c683dfff10551c708ff8c34ea4e175cb9bf2313865308fa23601e5a610e2f76838be7ded3b4d3a2c49d2d40fa20db51d1cc8ab20d330bb0dadb88b1a12853f0ecb7c7632947b098dcf435a54566bcf92befd55e03ee2a57d17524cd3d59d6e800c66059067e5eb6edb81946b3286950748240ec9afa4389f9b62bc92f94ec0fba9e64d6dc2f455f816016a4c5f3d507382ed5d3365",
                        "23");

        assertTrue(kh.verify("schmizz.net", 22, key));
View Full Code Here

        MachineCreationRequest request = buildMachineCreationRequest();

        PlatformLayerKey instanceKey = instance.getKey();
        request.tags.add(Tag.buildParentTag(instanceKey));

        PublicKey servicePublicKey = service.getSshKey().getKeyPair().getPublic();
        Instance created = computeClient.createInstance(cloud, request, servicePublicKey);

        {
          Tag instanceTag = Tag.build(Tag.ASSIGNED, created.getName());
          platformLayer.addTag(instance.getKey(), instanceTag);
View Full Code Here

  @Override
  protected void addChildren() throws OpsException {
    final GoogleCloudInstance model = OpsContext.get().getInstance(GoogleCloudInstance.class);

    PublicKey rootPublicKey;

    try {
      rootPublicKey = OpenSshUtils.readSshPublicKey(model.sshPublicKey);
    } catch (IOException e) {
      throw new OpsException("Cannot read SSH key");
View Full Code Here

    }

    public void computeK(BigInteger f)
            throws GeneralSecurityException {
        final KeyFactory keyFactory = SecurityUtils.getKeyFactory("DH");
        final PublicKey yourPubKey = keyFactory.generatePublic(new DHPublicKeySpec(f, p, g));
        agreement.doPhase(yourPubKey, true);
        K = new BigInteger(1, agreement.generateSecret());
    }
View Full Code Here

        this.kProv = kProv;
    }

    protected SSHPacket putPubKey(SSHPacket reqBuf)
            throws UserAuthException {
        PublicKey key;
        try {
            key = kProv.getPublic();
        } catch (IOException ioe) {
            throw new UserAuthException("Problem getting public key from " + kProv, ioe);
        }
View Full Code Here

        Certificate[] cert = keystore.getCertificateChain(alias);
        if (cert.length == 0) {
          log.warn("Ignoring zero length certificate chain for: " + alias);
          // continue;
        } else {
          PublicKey certPublicKey = cert[0].getPublicKey();

          String sigString = OpenSshUtils.getSignatureString(certPublicKey);
          publicKeySigs.add(sigString);
        }
        // }
View Full Code Here

            throw new UnsupportedTypeException(type);
        }
        try {
            KeyFactory kf = KeyFactory.getInstance(type.alg);

            PublicKey pubK = getPublicKey(type, pub);

            PKCS8EncodedKeySpec pks = new PKCS8EncodedKeySpec(pri);
            PrivateKey privK = kf.generatePrivate(pks);
            // FIXME verify that the keys are consistent if assertions/logging enabled??
View Full Code Here

        assertEquals(aliceS.length, curveToTest.derivedSecretSize);
        assertEquals(bobS.length, curveToTest.derivedSecretSize);
    }

    public void testGetPublicKey() {
        PublicKey aliceP = alice.getPublicKey();
        PublicKey bobP = bob.getPublicKey();
       
        assertNotNull(aliceP);
        assertNotSame(aliceP, bobP);
        assertEquals(aliceP.getEncoded().length, curveToTest.modulusSize);
        assertEquals(bobP.getEncoded().length, curveToTest.modulusSize);
    }
View Full Code Here

    public static void main(String[] args) throws InvalidKeyException, IllegalStateException, NoSuchAlgorithmException {
        Security.addProvider(new BouncyCastleProvider());
       
        ECDH alice = new ECDH(Curves.P256);
        ECDH bob = new ECDH(Curves.P256);
        PublicKey bobP = bob.getPublicKey();
        PublicKey aliceP = alice.getPublicKey();
       
        System.out.println("Alice C: "+alice.curve);
        System.out.println("Bob   C: "+bob.curve);
        System.out.println("Alice P: "+toHex(aliceP.getEncoded()));
        System.out.println("Bob   P: "+toHex(bobP.getEncoded()));
       
        System.out.println("Alice S: "+toHex(alice.getAgreedSecret(bob.getPublicKey())));
        System.out.println("Bob   S: "+toHex(bob.getAgreedSecret(alice.getPublicKey())));
    }
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.