public DerivedKeySecurityToken(string id, string algorithm,
                                       SecurityKeyIdentifierClause reference,
                                       SymmetricSecurityKey referencedKey,
                                       string name,
                                       int?generation,
                                       int?offset,
                                       int?length,
                                       string label,
                                       byte [] nonce)
        {
            algorithm = algorithm ?? SecurityAlgorithms.Psha1KeyDerivation;

            this.id         = id;
            this.algorithm  = algorithm;
            this.reference  = reference;
            this.generation = generation;
            this.offset     = offset;
            this.length     = length;
            this.nonce      = nonce;
            this.name       = name;
            this.label      = label;

            SecurityKey key = new InMemorySymmetricSecurityKey(
                referencedKey.GenerateDerivedKey(
                    algorithm,
                    Encoding.UTF8.GetBytes(label ?? Constants.WsscDefaultLabel),
                    nonce,
                    (length ?? 32) * 8,
                    offset ?? 0));

            keys = new ReadOnlyCollection <SecurityKey> (
                new SecurityKey [] { key });
        }
 public override byte[] GenerateDerivedKey(string algorithm, byte[] label, byte[] nonce, int derivedKeyLength, int offset)
 {
     return(_key.GenerateDerivedKey(algorithm, label, nonce, derivedKeyLength, offset));
 }