/// <summary>
        /// NewKey method implementation
        /// </summary>
        public string NewKey(string upn)
        {
            if (string.IsNullOrEmpty(upn))
            {
                return(null);
            }
            string lupn    = upn.ToLower();
            string strcert = string.Empty;

            if (_cryptoRSADataProvider == null)
            {
                _cryptoRSADataProvider = new Encryption();
            }
            _cryptoRSADataProvider.Certificate = CreateCertificate(lupn, _validity, out strcert);
            string crypted = AddKeyPrefix(_cryptoRSADataProvider.Encrypt(lupn));

            return(KeysStorage.NewUserKey(lupn, crypted, strcert));
        }
Exemplo n.º 2
0
            /// <summary>
            /// NewKey method implementation
            /// </summary>
            public override string NewKey(string upn)
            {
                if (string.IsNullOrEmpty(upn))
                {
                    return(null);
                }
                string lupn = upn.ToLower();
                RandomNumberGenerator cryptoRandomDataGenerator = new RNGCryptoServiceProvider();

                byte[] buffer  = null;
                string crypted = string.Empty;

                switch (_mode)
                {
                case KeyGeneratorMode.ClientSecret128:
                    buffer = new byte[16];
                    cryptoRandomDataGenerator.GetBytes(buffer);
                    break;

                case KeyGeneratorMode.ClientSecret256:
                    buffer = new byte[32];
                    cryptoRandomDataGenerator.GetBytes(buffer);
                    break;

                case KeyGeneratorMode.ClientSecret384:
                    buffer = new byte[48];
                    cryptoRandomDataGenerator.GetBytes(buffer);
                    break;

                case KeyGeneratorMode.ClientSecret512:
                    buffer = new byte[64];
                    cryptoRandomDataGenerator.GetBytes(buffer);
                    break;

                default:
                    buffer = Guid.NewGuid().ToByteArray();
                    cryptoRandomDataGenerator.GetBytes(buffer);
                    break;
                }
                crypted = AddKeyPrefix(Convert.ToBase64String(buffer));
                KeysStorage.NewUserKey(lupn, crypted);
                return(crypted);
            }
            /// <summary>
            /// NewKey method implementation
            /// </summary>
            public override string NewKey(string upn)
            {
                if (string.IsNullOrEmpty(upn))
                {
                    return(null);
                }
                string lupn = upn.ToLower();

                byte[] crypted = null;
                using (var prov = new RSAEncryption(_xorsecret))
                {
                    prov.Certificate = KeysStorage.CreateCertificate(lupn, _validity, true);
                    crypted          = prov.Encrypt(lupn);
                    if (crypted == null)
                    {
                        return(null);
                    }
                    string outkey = AddStorageInfos(crypted);
                    return(KeysStorage.NewUserKey(lupn, outkey, prov.Certificate));
                }
            }
Exemplo n.º 4
0
            /// <summary>
            /// NewKey method implementation
            /// </summary>
            public override string NewKey(string upn)
            {
                if (string.IsNullOrEmpty(upn))
                {
                    return(null);
                }
                string lupn = upn.ToLower();

                byte[] crypted = null;
                using (var prov = new RNGEncryption(_xorsecret, _mode))
                {
                    crypted = prov.Encrypt(lupn);
                    if (crypted == null)
                    {
                        return(null);
                    }
                }
                string outkey = AddStorageInfos(crypted);

                return(KeysStorage.NewUserKey(lupn, outkey));
            }
            /// <summary>
            /// NewKey method implementation
            /// </summary>
            public override string NewKey(string upn)
            {
                if (string.IsNullOrEmpty(upn))
                {
                    return(null);
                }
                string lupn = upn.ToLower();

                byte[] crypted = null;
                using (var prov = new RSAEncryption(_xorsecret, _certificatethumbprint))
                {
                    crypted = prov.Encrypt(lupn);
                    if (crypted == null)
                    {
                        return(null);
                    }
                }
                string outkey = AddKeyPrefix(System.Convert.ToBase64String(crypted));

                return(KeysStorage.NewUserKey(lupn, outkey));
            }
            /// <summary>
            /// NewKey method implementation
            /// </summary>
            public override string NewKey(string upn)
            {
                if (string.IsNullOrEmpty(upn))
                {
                    return(null);
                }
                string lupn = upn.ToLower();

                byte[] crypted = null;
                using (var prov = new RSAEncryption(XORSecret, CertificateThumbprint))
                {
                    crypted = prov.NewEncryptedKey(lupn);
                    if (crypted == null)
                    {
                        return(null);
                    }
                }
                string outkey = AddStorageInfos(crypted);

                return(KeysStorage.NewUserKey(lupn, outkey));
            }
        /// <summary>
        /// NewKey method implementation
        /// </summary>
        public string NewKey(string upn)
        {
            if (string.IsNullOrEmpty(upn))
            {
                return(null);
            }
            string lupn = upn.ToLower();

            byte[] crypted = null;
            using (var prov = new AES256CNGEncryption(XORSecret))
            {
                crypted = prov.NewEncryptedKey(lupn);
                if (crypted == null)
                {
                    return(null);
                }
            }
            string outkey = AddStorageInfos(crypted);

            return(KeysStorage.NewUserKey(lupn, outkey));
        }
            /// <summary>
            /// NewKey method implementation
            /// </summary>
            public override string NewKey(string upn)
            {
                if (string.IsNullOrEmpty(upn))
                {
                    return(null);
                }
                string lupn = upn.ToLower();

                byte[] crypted = null;
                using (var prov = new Encryption(_xorsecret))
                {
                    prov.Certificate = KeysStorage.CreateCertificate(lupn, _validity, false);
                    crypted          = prov.Encrypt(lupn);
                    if (crypted == null)
                    {
                        return(null);
                    }
                    string outkey = AddKeyPrefix(System.Convert.ToBase64String(crypted));
                    return(KeysStorage.NewUserKey(lupn, outkey, prov.Certificate));
                }
            }
            /// <summary>
            /// NewKey method implementation
            /// </summary>
            public override string NewKey(string upn)
            {
                if (string.IsNullOrEmpty(upn))
                {
                    return(null);
                }
                string lupn = upn.ToLower();

                byte[] crypted = null;
                using (var prov = new RSAEncryption(XORSecret))
                {
                    string pass = CheckSumEncoding.CheckSumAsString(lupn);
                    prov.Certificate = KeysStorage.CreateCertificate(lupn, pass, Validity);
                    crypted          = prov.NewEncryptedKey(lupn);
                    if (crypted == null)
                    {
                        return(null);
                    }
                    string outkey = AddStorageInfos(crypted);
                    return(KeysStorage.NewUserKey(lupn, outkey, prov.Certificate));
                }
            }