Beispiel #1
0
        /// <summary>
        /// Validates the HAN keys
        /// </summary>
        //  Revision History
        //  MM/DD/YY Who Version ID Number Description
        //  -------- --- ------- -- ------ -------------------------------------------
        //  09/17/09 RCG 2.30.00           Created
        //  09/19/14 jrf 4.00.63 WR 534158 Modified way test details are set.
        //  05/23/17 CFB 4.72.00 WR 741323 Removed validation of HAN link key as it is no longer used in the meter
        private void ValidateHANKeys()
        {
            string NetworkKey = (string)CRegistryHelper.GetApplicationValue("GasPro", "Key");
            string LinkKey    = (string)CRegistryHelper.GetApplicationValue("GasPro", "GlobalLinkKey");
            ProcedureResultCodes ValidationResult = ProcedureResultCodes.COMPLETED;
            string Details = "";

            if (IsAborted == false)
            {
                //Network Key validation
                ValidationResult = m_AmiDevice.ValidateHANSecurityKeys(NetworkKey, CENTRON_AMI.HANKeys.NetworkKey);
                Details          = GetSecurityValidationDetails(ValidationResult);

                if (ProcedureResultCodes.INVALID_PARAM == ValidationResult)
                {
                    Details += ", " + TestResources.KeyNotConsistentWithRegistry;
                }

                AddTestDetail(TestResources.HANNetworkKey, GetResultString(ProcedureResultCodes.COMPLETED == ValidationResult),
                              Details);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Reads the encrypted key from the registry and decrypts the byte array.
        /// This version of GetSecurityKey can get either of the HAN security keys.
        /// </summary>
        /// <param name="IncludeSeqNbr">Whether or not to include the sequence
        /// number at the start of the key</param>
        /// <param name="KeyName">The name of the key to fetch - either the
        /// network key or the global link key
        /// </param>
        /// <returns>the decrypted key as a byte array</returns>
        //
        // Revision History
        // MM/DD/YY who Version Issue# Description
        // -------- --- ------- ------ ---------------------------------------
        // 03/11/08 AF  1.50.04        Created
        // 10/02/09 AF  2.30.05        Added Compare() parameter for compiler warning
        // 11/25/09 AF  2.30.22        Changed String.Compare() to quiet compiler warning
        // 06/12/12 RCG 2.70.77        Changed to use the Secured Encryption Keys

        protected byte[] GetSecurityKey(bool IncludeSeqNbr, string KeyName)
        {
            byte[] DecryptedKeyWithSeqNumber = new byte[17];
            byte[] DecryptedKey;

            string EncryptedKey = (string)CRegistryHelper.GetApplicationValue("GasPro", KeyName);

            DecryptedKey = DecryptHANKey(EncryptedKey);

            // By definition the sequence number is the first byte of the key
            DecryptedKeyWithSeqNumber[0] = DecryptedKey[0];
            Array.Copy(DecryptedKey, 0, DecryptedKeyWithSeqNumber, 1, DecryptedKey.Length);

            if (IncludeSeqNbr)
            {
                return(DecryptedKeyWithSeqNumber);
            }
            else
            {
                return(DecryptedKey);
            }
        }