コード例 #1
0
        static EncryptingCredentials GetWrappingCredentialsFromProtectedKey( ProtectedKey protectedKey )
        {
            if ( protectedKey == null )
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull( "protectedKey" );
            }

            return protectedKey.WrappingCredentials;
        }
コード例 #2
0
        /// <summary>
        /// Constructs a requested proof token instance with the protected key.
        /// </summary>
        /// <param name="protectedKey">The protected key which can be either binary secret or encrypted key.</param>
        public RequestedProofToken(ProtectedKey protectedKey)
        {
            if (protectedKey == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("protectedKey");
            }

            _keys = protectedKey;
        }
コード例 #3
0
        static byte[] GetKeyBytesFromProtectedKey( ProtectedKey protectedKey )
        {
            if ( protectedKey == null )
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull( "protectedKey" );
            }

            return protectedKey.GetKeyBytes();
        }
コード例 #4
0
ファイル: RequestedProofToken.cs プロジェクト: nlhepler/mono
		public RequestedProofToken (Byte[] secret) {
			ProtectedKey = new ProtectedKey (secret);
		}
コード例 #5
0
ファイル: RequestedProofToken.cs プロジェクト: nlhepler/mono
		public RequestedProofToken (ProtectedKey protectedKey) {
			ProtectedKey = protectedKey;
		}
コード例 #6
0
ファイル: Entropy.cs プロジェクト: nlhepler/mono
		public Entropy (ProtectedKey protectedKey) : base (protectedKey.GetKeyBytes (), protectedKey.WrappingCredentials)
		{ }
コード例 #7
0
 /// <summary>
 /// Constructs an entropy instance with the protected key.
 /// </summary>
 /// <param name="protectedKey">The protected key which can be either binary secret or encrypted key.</param>
 public Entropy( ProtectedKey protectedKey )
     : base( GetKeyBytesFromProtectedKey( protectedKey ), GetWrappingCredentialsFromProtectedKey( protectedKey ) )
 {
 }
コード例 #8
0
 public RequestedProofToken(Byte[] secret)
 {
     ProtectedKey = new ProtectedKey(secret);
 }
コード例 #9
0
        // This method reads the binary secret or encrypted key 
        public static ProtectedKey ReadProtectedKey(XmlReader reader, WSTrustSerializationContext context, WSTrustConstantsAdapter trustConstants)
        {
            if (reader == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
            }

            if (trustConstants == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("trustConstants");
            }

            ProtectedKey protectedKey = null;

            if (!reader.IsEmptyElement)
            {
                if (reader.IsStartElement(trustConstants.Elements.BinarySecret, trustConstants.NamespaceURI))
                {
                    // BinarySecret case
                    BinarySecretSecurityToken token = ReadBinarySecretSecurityToken(reader, trustConstants);
                    byte[] secret = token.GetKeyBytes();
                    protectedKey = new ProtectedKey(secret);
                }
                else if (context.SecurityTokenHandlers.CanReadKeyIdentifierClause(reader))
                {
                    // EncryptedKey case
                    EncryptedKeyIdentifierClause encryptedKeyClause = context.SecurityTokenHandlers.ReadKeyIdentifierClause(reader) as EncryptedKeyIdentifierClause;

                    if (encryptedKeyClause != null)
                    {
                        SecurityKey wrappingKey = null;
                        byte[] secret;

                        foreach (SecurityKeyIdentifierClause wrappingKeyClause in encryptedKeyClause.EncryptingKeyIdentifier)
                        {
                            if (context.TokenResolver.TryResolveSecurityKey(wrappingKeyClause, out wrappingKey))
                            {
                                break;
                            }
                        }

                        if (wrappingKey == null)
                        {
                            // We can't resolve the ski, throw
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WSTrustSerializationException(SR.GetString(SR.ID3027, "the SecurityHeaderTokenResolver or OutOfBandTokenResolver")));
                        }

                        secret = wrappingKey.DecryptKey(encryptedKeyClause.EncryptionMethod, encryptedKeyClause.GetEncryptedKey());
                        EncryptingCredentials wrappingCredentials = new EncryptingCredentials(wrappingKey, encryptedKeyClause.EncryptingKeyIdentifier, encryptedKeyClause.EncryptionMethod);

                        protectedKey = new ProtectedKey(secret, wrappingCredentials);
                    }
                }
            }

            return protectedKey;
        }
コード例 #10
0
ファイル: Entropy.cs プロジェクト: dox0/DotNet471RS3
 /// <summary>
 /// Constructs an entropy instance with the protected key.
 /// </summary>
 /// <param name="protectedKey">The protected key which can be either binary secret or encrypted key.</param>
 public Entropy(ProtectedKey protectedKey)
     : base(GetKeyBytesFromProtectedKey(protectedKey), GetWrappingCredentialsFromProtectedKey(protectedKey))
 {
 }
コード例 #11
0
 /// <summary>
 /// When the requested proof token contains real key encrypted.
 /// </summary>
 /// <param name="secret">The key material.</param>
 /// <param name="wrappingCredentials">The encrypting credentials to encrypt the key material.</param>
 public RequestedProofToken(byte[] secret, EncryptingCredentials wrappingCredentials)
 {
     _keys = new ProtectedKey(secret, wrappingCredentials);
 }
コード例 #12
0
 /// <summary>
 /// When the requested proof token contains real key in plain text.
 /// </summary>
 /// <param name="secret">The key material.</param>
 public RequestedProofToken(byte[] secret)
 {
     _keys = new ProtectedKey(secret);
 }
コード例 #13
0
 /// <summary>
 /// When the requested proof token contains real key in plain text.
 /// </summary>
 /// <param name="secret">The key material.</param>
 public RequestedProofToken(byte[] secret)
 {
     _keys = new ProtectedKey(secret);
 }
コード例 #14
0
ファイル: RequestedProofToken.cs プロジェクト: nlhepler/mono
		public RequestedProofToken (Byte[] secret, EncryptingCredentials wrappingCredentials) {
			ProtectedKey = new ProtectedKey (secret, wrappingCredentials);
		}
コード例 #15
0
        public static void WriteProtectedKey(XmlWriter writer, ProtectedKey protectedKey, WSTrustSerializationContext context, WSTrustConstantsAdapter trustConstants)
        {
            if (writer == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
            }

            if (protectedKey == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("protectedKey");
            }

            if (trustConstants == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("trustConstants");
            }

            if (protectedKey.WrappingCredentials != null)
            {
                byte[] encryptedKey = protectedKey.WrappingCredentials.SecurityKey.EncryptKey(protectedKey.WrappingCredentials.Algorithm, protectedKey.GetKeyBytes());
                EncryptedKeyIdentifierClause clause = new EncryptedKeyIdentifierClause(encryptedKey, protectedKey.WrappingCredentials.Algorithm, protectedKey.WrappingCredentials.SecurityKeyIdentifier);
                context.SecurityTokenHandlers.WriteKeyIdentifierClause(writer, clause);
            }
            else
            {
                BinarySecretSecurityToken entropyToken = new BinarySecretSecurityToken(protectedKey.GetKeyBytes());
                WriteBinarySecretSecurityToken(writer, entropyToken, trustConstants);
            }
        }
コード例 #16
0
ファイル: Entropy.cs プロジェクト: sampsonye/myMono
 public Entropy(ProtectedKey protectedKey) : base(protectedKey.GetKeyBytes(), protectedKey.WrappingCredentials)
 {
 }
コード例 #17
0
 public RequestedProofToken(ProtectedKey protectedKey)
 {
     ProtectedKey = protectedKey;
 }