Examples of DerivationAlgorithm


Examples of org.apache.ws.sandbox.security.conversation.dkalgo.DerivationAlgorithm

        log.debug("KeyDerivator: deriving key from contecxt :" + convSession.getContextInfo().getIdentifier() + " for dkt: " + dkInfo.getId());
        byte[] secret = convSession.getContextInfo().getSharedSecret(); //Shared secret
        String labelAndNonce = getLabelAndNonce(convSession, dkInfo); //Label and nonce
        long keyLength = getKeyLength(convSession, dkInfo); //Length of the key to generated
        int offset = getOffset(convSession, dkInfo);
        DerivationAlgorithm derivationAlgo = AlgoFactory.getInstance(dkInfo.
                getAlgorithm()); //Derivation algorithm
        return derivationAlgo.createKey(secret, labelAndNonce, offset, keyLength);
    }
View Full Code Here

Examples of org.apache.ws.security.conversation.dkalgo.DerivationAlgorithm

        }
    }

    private void deriveKey() throws WSSecurityException{
        try {
            DerivationAlgorithm algo = AlgoFactory.getInstance(this.algorithm);
            byte[] labelBytes = null;
            if(label == null || (label != null && label.length() == 0)) {
                labelBytes = ConversationConstants.DEFAULT_LABEL.getBytes("UTF-8");
            } else {
                labelBytes = this.label.getBytes("UTF-8");
            }
           
            byte[] seed = new byte[labelBytes.length + nonce.length];
            System.arraycopy(labelBytes, 0, seed, 0, labelBytes.length);
            System.arraycopy(nonce, 0, seed, labelBytes.length, nonce.length);
           
            this.keyBytes = algo.createKey(this.secret, seed, offset, length);
           
        } catch (Exception e) {
            throw new WSSecurityException(e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.apache.ws.security.conversation.dkalgo.DerivationAlgorithm

       
        byte[] seed = new byte[label.length + nonce.length];
        System.arraycopy(label, 0, seed, 0, label.length);
        System.arraycopy(nonce, 0, seed, label.length, nonce.length);
       
        DerivationAlgorithm algo = AlgoFactory.getInstance(ConversationConstants.DerivationAlgorithm.P_SHA_1);
       
        this.derivedKeyBytes = algo.createKey(this.ephemeralKey, seed, offset, length);
       
       
        //Add the DKTs
        dkt = new DerivedKeyToken(document);
        dktId = "derivedKeyId-" + dkt.hashCode();
View Full Code Here

Examples of org.apache.ws.security.conversation.dkalgo.DerivationAlgorithm

       
        byte[] seed = new byte[label.length + nonce.length];
        System.arraycopy(label, 0, seed, 0, label.length);
        System.arraycopy(nonce, 0, seed, label.length, nonce.length);
       
        DerivationAlgorithm algo = AlgoFactory.getInstance(ConversationConstants.DerivationAlgorithm.P_SHA_1);
       
        this.derivedKeyBytes = algo.createKey(this.ephemeralKey, seed, offset, length);
       
       
        //Add the DKTs
        dkt = new DerivedKeyToken(this.wscVersion, document);
        dktId = "derivedKeyId-" + dkt.hashCode();
View Full Code Here

Examples of org.apache.ws.security.conversation.dkalgo.DerivationAlgorithm

        }
    }

    private void deriveKey() throws WSSecurityException{
        try {
            DerivationAlgorithm algo = AlgoFactory.getInstance(this.algorithm);
            byte[] labelBytes = null;
            if(label == null || (label != null && label.length() == 0)) {
                labelBytes = (ConversationConstants.DEFAULT_LABEL + ConversationConstants.DEFAULT_LABEL)
                        .getBytes("UTF-8");
            } else {
                labelBytes = this.label.getBytes("UTF-8");
            }
           
            byte[] seed = new byte[labelBytes.length + nonce.length];
            System.arraycopy(labelBytes, 0, seed, 0, labelBytes.length);
            System.arraycopy(nonce, 0, seed, labelBytes.length, nonce.length);
           
            this.keyBytes = algo.createKey(this.secret, seed, offset, length);
           
        } catch (Exception e) {
            throw new WSSecurityException(e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.apache.ws.security.conversation.dkalgo.DerivationAlgorithm

        }
    }

    private void deriveKey() throws WSSecurityException{
        try {
            DerivationAlgorithm algo = AlgoFactory.getInstance(this.algorithm);
            byte[] labelBytes = null;
            if (label == null || label.length() == 0) {
                labelBytes =
                    (ConversationConstants.DEFAULT_LABEL + ConversationConstants.DEFAULT_LABEL).getBytes("UTF-8");
            } else {
                labelBytes = this.label.getBytes("UTF-8");
            }
           
            byte[] seed = new byte[labelBytes.length + nonce.length];
            System.arraycopy(labelBytes, 0, seed, 0, labelBytes.length);
            System.arraycopy(nonce, 0, seed, labelBytes.length, nonce.length);
           
            this.keyBytes = algo.createKey(this.secret, seed, offset, length);
           
        } catch (Exception e) {
            throw new WSSecurityException(
                WSSecurityException.FAILURE, null, null, e
            );
View Full Code Here

Examples of org.apache.ws.security.conversation.dkalgo.DerivationAlgorithm

       
        byte[] seed = new byte[label.length + nonce.length];
        System.arraycopy(label, 0, seed, 0, label.length);
        System.arraycopy(nonce, 0, seed, label.length, nonce.length);
       
        DerivationAlgorithm algo =
            AlgoFactory.getInstance(ConversationConstants.DerivationAlgorithm.P_SHA_1);
       
        this.derivedKeyBytes = algo.createKey(this.ephemeralKey, seed, offset, length);
       
        // Add the DKTs
        dkt = new DerivedKeyToken(this.wscVersion, document);
        dktId = wssConfig.getIdAllocator().createId("derivedKeyId-", dkt);
       
View Full Code Here

Examples of org.apache.ws.security.conversation.dkalgo.DerivationAlgorithm

     * @param secret
     * @throws WSSecurityException
     */
    public byte[] deriveKey(int length, byte[] secret) throws WSSecurityException {
        try {
            DerivationAlgorithm algo = AlgoFactory.getInstance(getAlgorithm());
            byte[] labelBytes = null;
            String label = getLabel();
            if (label == null || label.length() == 0) {
                labelBytes =
                    (ConversationConstants.DEFAULT_LABEL
                        + ConversationConstants.DEFAULT_LABEL).getBytes("UTF-8");
            } else {
                labelBytes = label.getBytes("UTF-8");
            }
           
            byte[] nonce = Base64.decode(getNonce());
            byte[] seed = new byte[labelBytes.length + nonce.length];
            System.arraycopy(labelBytes, 0, seed, 0, labelBytes.length);
            System.arraycopy(nonce, 0, seed, labelBytes.length, nonce.length);
           
            if (length <= 0) {
                length = getLength();
            }
            return algo.createKey(secret, seed, getOffset(), length);
           
        } catch (Exception e) {
            throw new WSSecurityException(
                WSSecurityException.FAILURE, null, null, e
            );
View Full Code Here

Examples of org.apache.ws.security.conversation.dkalgo.DerivationAlgorithm

       
        byte[] seed = new byte[label.length + nonce.length];
        System.arraycopy(label, 0, seed, 0, label.length);
        System.arraycopy(nonce, 0, seed, label.length, nonce.length);
       
        DerivationAlgorithm algo =
            AlgoFactory.getInstance(ConversationConstants.DerivationAlgorithm.P_SHA_1);
       
        derivedKeyBytes = algo.createKey(ephemeralKey, seed, offset, length);
       
        // Add the DKTs
        dkt = new DerivedKeyToken(wscVersion, document);
        dktId = getWsConfig().getIdAllocator().createId("DK-", dkt);
       
View Full Code Here

Examples of org.apache.ws.security.conversation.dkalgo.DerivationAlgorithm

       
        byte[] seed = new byte[label.length + nonce.length];
        System.arraycopy(label, 0, seed, 0, label.length);
        System.arraycopy(nonce, 0, seed, label.length, nonce.length);
       
        DerivationAlgorithm algo = AlgoFactory.getInstance(ConversationConstants.DerivationAlgorithm.P_SHA_1);
       
        this.derivedKeyBytes = algo.createKey(this.ephemeralKey, seed, offset, length);
       
       
        //Add the DKTs
        dkt = new DerivedKeyToken(this.wscVersion, document);
        dktId = "derivedKeyId-" + dkt.hashCode();
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.