Examples of DSAPrivateKey


Examples of ch.ethz.ssh2.signature.DSAPrivateKey

      Object key = PEMDecoder.decode(PEMPrivateKey, password);

      if (key instanceof DSAPrivateKey)
      {
        DSAPrivateKey pk = (DSAPrivateKey) key;

        byte[] pk_enc = DSASHA1Verify.encodeSSHDSAPublicKey(pk.getPublicKey());

        TypesWriter tw = new TypesWriter();

        byte[] H = tm.getSessionIdentifier();

        tw.writeString(H, 0, H.length);
        tw.writeByte(Packets.SSH_MSG_USERAUTH_REQUEST);
        tw.writeString(user);
        tw.writeString("ssh-connection");
        tw.writeString("publickey");
        tw.writeBoolean(true);
        tw.writeString("ssh-dss");
        tw.writeString(pk_enc, 0, pk_enc.length);

        byte[] msg = tw.getBytes();

        DSASignature ds = DSASHA1Verify.generateSignature(msg, pk, rnd);

        byte[] ds_enc = DSASHA1Verify.encodeSSHDSASignature(ds);

        PacketUserauthRequestPublicKey ua = new PacketUserauthRequestPublicKey("ssh-connection", user,
            "ssh-dss", pk_enc, ds_enc);
        tm.sendMessage(ua.getPayload());
      }
      else if (key instanceof RSAPrivateKey)
      {
        RSAPrivateKey pk = (RSAPrivateKey) key;

        byte[] pk_enc = RSASHA1Verify.encodeSSHRSAPublicKey(pk.getPublicKey());

        TypesWriter tw = new TypesWriter();
        {
          byte[] H = tm.getSessionIdentifier();
View Full Code Here

Examples of ch.ethz.ssh2.signature.DSAPrivateKey

      BigInteger x = dr.readInt();

      if (dr.available() != 0)
        throw new IOException("Padding in DSA PRIVATE KEY DER stream.");

      return new DSAPrivateKey(p, q, g, y, x);
    }

    if (ps.pemType == PEM_RSA_PRIVATE_KEY)
    {
      SimpleDERReader dr = new SimpleDERReader(ps.data);
View Full Code Here

Examples of com.trilead.ssh2.signature.DSAPrivateKey

      Object key = PEMDecoder.decode(PEMPrivateKey, password);

      if (key instanceof DSAPrivateKey)
      {
        DSAPrivateKey pk = (DSAPrivateKey) key;

        byte[] pk_enc = DSASHA1Verify.encodeSSHDSAPublicKey(pk.getPublicKey());

        TypesWriter tw = new TypesWriter();

        byte[] H = tm.getSessionIdentifier();

        tw.writeString(H, 0, H.length);
        tw.writeByte(Packets.SSH_MSG_USERAUTH_REQUEST);
        tw.writeString(user);
        tw.writeString("ssh-connection");
        tw.writeString("publickey");
        tw.writeBoolean(true);
        tw.writeString("ssh-dss");
        tw.writeString(pk_enc, 0, pk_enc.length);

        byte[] msg = tw.getBytes();

        DSASignature ds = DSASHA1Verify.generateSignature(msg, pk, rnd);

        byte[] ds_enc = DSASHA1Verify.encodeSSHDSASignature(ds);

        PacketUserauthRequestPublicKey ua = new PacketUserauthRequestPublicKey("ssh-connection", user,
            "ssh-dss", pk_enc, ds_enc);
        tm.sendMessage(ua.getPayload());
      }
      else if (key instanceof RSAPrivateKey)
      {
        RSAPrivateKey pk = (RSAPrivateKey) key;

        byte[] pk_enc = RSASHA1Verify.encodeSSHRSAPublicKey(pk.getPublicKey());

        TypesWriter tw = new TypesWriter();
        {
          byte[] H = tm.getSessionIdentifier();
View Full Code Here

Examples of freenet.crypt.DSAPrivateKey

        keywordHash = md256.digest(keyword.getBytes("UTF-8"));
      } catch (UnsupportedEncodingException e) {
        throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e);
      }
      MersenneTwister mt = new MersenneTwister(keywordHash);
      DSAPrivateKey privKey = new DSAPrivateKey(Global.DSAgroupBigA, mt);
      DSAPublicKey pubKey = new DSAPublicKey(Global.DSAgroupBigA, privKey);
      byte[] pubKeyHash = md256.digest(pubKey.asBytes());
      try {
        return new ClientKSK(keyword, pubKeyHash, pubKey, privKey, keywordHash);
      } catch (MalformedURLException e) {
View Full Code Here

Examples of freenet.crypt.DSAPrivateKey

    // However, we recommend that you not use this, especially not for a freesite, as
    // SSK@blah,blah,blah//filename is confusing for clients, browsers etc.
    if(uri.getDocName() == null)
      throw new MalformedURLException("SSK URIs must have a document name (to avoid ambiguity)");
    DSAGroup g = Global.DSAgroupBigA;
    DSAPrivateKey privKey;
    try {
      privKey = new DSAPrivateKey(new NativeBigInteger(1, uri.getRoutingKey()), g);
    } catch(IllegalArgumentException e) {
      // DSAPrivateKey is invalid
      Logger.error(InsertableClientSSK.class, "Caught "+e, e);
      throw new MalformedURLException("SSK private key (routing key) is invalid: " + e);
    }
View Full Code Here

Examples of freenet.crypt.DSAPrivateKey

  public static InsertableClientSSK createRandom(RandomSource r, String docName) {
    byte[] ckey = new byte[CRYPTO_KEY_LENGTH];
    r.nextBytes(ckey);
    DSAGroup g = Global.DSAgroupBigA;
    DSAPrivateKey privKey = new DSAPrivateKey(g, r);
    DSAPublicKey pubKey = new DSAPublicKey(g, privKey);
    try {
      byte[] pkHash = SHA256.digest(pubKey.asBytes());
      return new InsertableClientSSK(docName, pkHash, pubKey, privKey, ckey,
          Key.ALGO_AES_PCFB_256_SHA256);
View Full Code Here

Examples of freenet.crypt.DSAPrivateKey

    new RAMFreenetStore<DSAPublicKey>(pk, keys);
    DSAGroup group = Global.DSAgroupBigA;
    Random random = new MersenneTwister(1010101);
    HashMap<ByteArrayWrapper, DSAPublicKey> map = new HashMap<ByteArrayWrapper, DSAPublicKey>();
    for(int i=0;i<keys;i++) {
      DSAPrivateKey privKey = new DSAPrivateKey(group, random);
      DSAPublicKey key = new DSAPublicKey(group, privKey);
      byte[] hash = key.asBytesHash();
      ByteArrayWrapper w = new ByteArrayWrapper(hash);
      map.put(w, key.cloneKey());
      pk.put(hash, key, false);
View Full Code Here

Examples of freenet.crypt.DSAPrivateKey

    GetPubkey pubkeys = new SimpleGetPubkey(pk);
    DSAGroup group = Global.DSAgroupBigA;
    Random random = new MersenneTwister(1010101);
    HashMap<ByteArrayWrapper, DSAPublicKey> map = new HashMap<ByteArrayWrapper, DSAPublicKey>();
    for(int i=0;i<keys;i++) {
      DSAPrivateKey privKey = new DSAPrivateKey(group, random);
      DSAPublicKey key = new DSAPublicKey(group, privKey);
      byte[] hash = key.asBytesHash();
      ByteArrayWrapper w = new ByteArrayWrapper(hash);
      map.put(w, key.cloneKey());
      pubkeys.cacheKey(hash, key, false, false, false, false, false);
View Full Code Here

Examples of freenet.crypt.DSAPrivateKey

   
    final int CRYPTO_KEY_LENGTH = 32;
    byte[] ckey = new byte[CRYPTO_KEY_LENGTH];
    random.nextBytes(ckey);
    DSAGroup g = Global.DSAgroupBigA;
    DSAPrivateKey privKey = new DSAPrivateKey(g, random);
    DSAPublicKey pubKey = new DSAPublicKey(g, privKey);
    byte[] pkHash = SHA256.digest(pubKey.asBytes());
    String docName = "myDOC";
    InsertableClientSSK ik = new InsertableClientSSK(docName, pkHash, pubKey, privKey, ckey, Key.ALGO_AES_PCFB_256_SHA256);
   
View Full Code Here

Examples of freenet.crypt.DSAPrivateKey

   
    final int CRYPTO_KEY_LENGTH = 32;
    byte[] ckey = new byte[CRYPTO_KEY_LENGTH];
    random.nextBytes(ckey);
    DSAGroup g = Global.DSAgroupBigA;
    DSAPrivateKey privKey = new DSAPrivateKey(g, random);
    DSAPublicKey pubKey = new DSAPublicKey(g, privKey);
    byte[] pkHash = SHA256.digest(pubKey.asBytes());
    String docName = "myDOC";
    InsertableClientSSK ik = new InsertableClientSSK(docName, pkHash, pubKey, privKey, ckey, Key.ALGO_AES_PCFB_256_SHA256);
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.