Examples of DSAPublicKey


Examples of freenet.crypt.DSAPublicKey

  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);
    } catch (MalformedURLException e) {
      throw new Error(e);
    }
View Full Code Here

Examples of freenet.crypt.DSAPublicKey

    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);
      assertTrue(pk.fetch(hash, false, false, null).equals(key));
    }
    int x = 0;
    for(Map.Entry<ByteArrayWrapper, DSAPublicKey> entry : map.entrySet()) {
View Full Code Here

Examples of freenet.crypt.DSAPublicKey

    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);
      assertTrue(pubkeys.getKey(hash, false, false, null).equals(key));
    }
    int x = 0;
    for(Map.Entry<ByteArrayWrapper, DSAPublicKey> entry : map.entrySet()) {
View Full Code Here

Examples of freenet.crypt.DSAPublicKey

    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);
   
    String test = "test";
    SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(test.getBytes("UTF-8"));
View Full Code Here

Examples of freenet.crypt.DSAPublicKey

    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);
   
    String test = "test";
    SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(test.getBytes("UTF-8"));
View Full Code Here

Examples of freenet.crypt.DSAPublicKey

        throw new FSParseException("Changed DSA group?!");
    }

    sfs = fs.subset("dsaPubKey");
    if(sfs != null) {
      DSAPublicKey key;
      key = DSAPublicKey.create(sfs, peerCryptoGroup);
      if(!key.equals(this.peerPubKey))
        throw new FSParseException("Changed pubkey?!");
    }

    String newVersion = fs.get("version");
    if(newVersion == null) {
View Full Code Here

Examples of freenet.crypt.DSAPublicKey

   */
  public void initCrypto() {
    MessageDigest md = SHA256.getMessageDigest();
    cryptoGroup = Global.DSAgroupBigA;
    privKey = new DSAPrivateKey(cryptoGroup, random);
    pubKey = new DSAPublicKey(cryptoGroup, privKey);
    myARK = InsertableClientSSK.createRandom(random, "ark");
    myARKNumber = 0;
    SHA256.returnMessageDigest(md);
    clientNonce = new byte[32];
    node.random.nextBytes(clientNonce);
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

            KeyPair pair = keyGen.generateKeyPair();

            // Get the keys
            DSAPrivateKey prvKey = (DSAPrivateKey) pair.getPrivate();
            DSAPublicKey pubKey = (DSAPublicKey) pair.getPublic();

            // Set the private key (the public is automatically generated)
            setPrivateKey(new SshDssPrivateKey(prvKey));
        } catch (NoSuchAlgorithmException nsae) {
        }
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

        PublicKey pubKey = cert.getPublicKey();
        if (!(pubKey instanceof DSAPublicKey))
        {
            return pubKey;
        }
        DSAPublicKey dsaPubKey = (DSAPublicKey)pubKey;
        if (dsaPubKey.getParams() != null)
        {
            return dsaPubKey;
        }
        for (int i = index + 1; i < certs.size(); i++)
        {
            X509Certificate parentCert = (X509Certificate)certs.get(i);
            pubKey = parentCert.getPublicKey();
            if (!(pubKey instanceof DSAPublicKey))
            {
                throw new CertPathValidatorException(
                    "DSA parameters cannot be inherited from previous certificate.");
            }
            DSAPublicKey prevDSAPubKey = (DSAPublicKey)pubKey;
            if (prevDSAPubKey.getParams() == null)
            {
                continue;
            }
            DSAParams dsaParams = prevDSAPubKey.getParams();
            DSAPublicKeySpec dsaPubKeySpec = new DSAPublicKeySpec(
                dsaPubKey.getY(), dsaParams.getP(), dsaParams.getQ(), dsaParams.getG());
            try
            {
                KeyFactory keyFactory = KeyFactory.getInstance("DSA", BouncyCastleProvider.PROVIDER_NAME);
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

        if (!(o instanceof DSAPublicKey))
        {
            return false;
        }
       
        DSAPublicKey other = (DSAPublicKey)o;
       
        return this.getY().equals(other.getY())
            && this.getParams().getG().equals(other.getParams().getG())
            && this.getParams().getP().equals(other.getParams().getP())
            && this.getParams().getQ().equals(other.getParams().getQ());
    }
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.