DOQ-Dimel-009 (EN)
DOQ-Dimel-009 (EN)
ORIENTATIONS FOR EDITING SOFTWARE DESCRIPTIVE MEMORY FOR ELECTRIC POWER METERS
Guidance Document
DOQ-DIMEL-009
Review 00 – November/2018
2. APPLICATION FIELD
It applies to applicants and laboratories involved in the software evaluation process of the legal
metrology board.
3. RESPONSIBILITY
The responsibility for the approval, revision and cancellation of this Standard befalls to Sinst.
4. REFERENCE DOCUMENTATION
Inmetro Ordinance nº371 Approves the technical and metrological requirements as minimum
from Sep 28th, 2007 conditions to be met by Centralized Measurement Systems for use in
measuring electric power in consumer units.
Inmetro Ordinance nº586 Approves the metrological technical regulation of software for electronic
from Nov 1st, 2012 power meters and software for distributed power measurement
systems.
Inmetro Ordinance nº587 Approves the technical metrological regulation for active and/or reactive
from Nov 5th, 2012 electronic meters, single-phase and multi-phase, including the
reconditioned ones.
Inmetro Ordinance nº232 International Metrology Vocabulary: Fundamental and General Concepts
from May 8th, 2012 and Associated Terms (VIM) – 1st Luso-Brazilian Edition (2012).
Inmetro Ordinance nº163 International Vocabulary of Legal Metrology Terms
from Sep 6th, 2005
OIML D 31 General requirements for software-controlled measuring instruments –
OIML, 2008
OIML D 11 General requirements for electronic measuring instruments – OIML,
2004
WELMEC Software Guide Measuring Instruments Directive 2004/22/EC – WELMEC, March 2012
7.2 Issue 5
Inmetro’s meeting Software security and interoperability
minutes Jun 23rd, Jul 2nd,
Jul 3rd, Sep 22nd; 2015
SP 800-22 A Statistical Test Suite for Random and Pseudorandom Number
Generator for Cryptographic Applications
SP 800-57 Recommendation for Key Management, Part 1: General
5. COMPLEMENTARY DOCUMENTS
NIT-Sinst-003 Organization of documentations for the software evaluation process
NIT-Sinst-019 Software analysis for the evaluation of instrument/power measurement
system model
Plan-Sinst-019 Software Evaluation Record Worksheet for Evaluation of
Instrument/Power Metering Systems Models
6. DEFINITIONS
6.1. Acronyms
Inmetro’s UP/UO acronyms can be accessed at:
http://intranet.inmetro.gov.br/tema/qualidade/docs/pdf/siglas-inmetro.pdf
SDMEE Sistema Distribuído de Medição de Energia Elétrica (Distributed Power Measurement System)
6.2. Terms
6.2.1. Binary File
Computer file that is not in text format, coming from the compilation of a source code, which contains
legally relevant software.
6.2.10. Checksum
Code used to verify the integrity of transmitted data.
6.2.14. State
Establishes the current set of system conditions. In a given state the system behaves, waits for a trigger
or performs some action.
a) The software is built exclusively for measurement purposes. Additionally, functions for software and
data protection, data transmission and software loading are considered to be built for measurement
purposes.
b) The user interface is dedicated for the measurement purpose.
c) An operating system (OS) or subsystem can be included if only legally relevant software has external
communication; if it does not allow you to load or change programs, parameters or data or run
programs; if it does not allow changing the environment of the legally relevant application; and
includes access control and does not allow for a subsequent change in access control configuration.
d) The software environment is invariable and there are no internal or external means to program or
change the software in its embedded status except when the software load requirements are met.
6.2.19. Interrupt
Hardware interrupt is a signal form a device sent to the processor in order to interrupt the usual flow of
instructions for an execution exception to be handled.
6.2.34. Applicant
It is every legal, public or private entity, national or foreign, headquartered in Brazil, that develops
activities of production, assembly, creation, construction, transformation, import, export, distribution or
sale of instruments.
a) Blue Tariff: modality structured for the application of differentiated tariffs of electric energy
consumption according to the hours of use in a day and the periods of the year, as well as
differentiated rates of power demand according to the hours of use in a day; and
b) Green Tariff: modality structured for the application of differentiated rates of energy consumption
according to the hours of use in a day and the periods of the year, as well as a single rate for power
demand.
Note – The documentation to be delivered is detailed in NIT-Sinst-003. This guidance document only
covers one of the documentation items, the software’s descriptive memo.
If the measuring instrument has more than one embedded firmware, henceforth a module, the
software’s descriptive memorial must describe in detail the service for the requirements of each module
that makes up the measurement system. If the documentation is very extensive and the measurement
system has many modules, the software memorial can be divided into multiple documents, one for each
module.
Note – The appropriate safeguards for the information contained in the documentation are described in
the NIT-Sinst-003 document.
It should be described in detail: the features that support the execution of the software (memory,
processor/microcontroller); the static (software architecture) and dynamic aspects (execution flows) of
the software; specific block features that contribute for the measuring system’s functioning as a whole
(specific features of the display and the meter, for example); physical protection mechanisms (sealed
box or not, for example).
The documents that describe the instrument are specified in item 8 of NIT-Sinst-003. If it is the
applicant’s interest, the documents described in items 8.2 and 8.3 of NIT-Sinst-003 may be linked to the
software’s memorial. In addition to the documents of item 8 in NIT-Sinst-003, the software’s descriptive
memo should contain the following information.
(i) Automation routines that control the measurement dynamics are part of the legally relevant chain.
(ii) Software components that prepare legally relevant data for storage or transmission, or that
perform data verification after reading or receiving, are legally relevant software.
(iii) Automation routines that control the measurement dynamics are part of the legally relevant chain.
7.2.1.4. Memory
Describe: Type, Quantity, Map, etc. Figure 1 shows an example of a memory map.
The applicant should provide a figure on the memory organization. All block memories, even the
auxiliary ones (temporarily used in the software loading process, for example), are subject to integrity
checking. NIT-Sinst-020 Annex A discusses two integrity check procedures.
The applicant should pay special attention to completing the various reports and must justify those
which have not been fully or partially fulfilled. To avoid an attack using unoccupied memory space, it
must be filled with random numbers known by Inmetro. Thus, the memory of the microcontroller will
have an organization similar to that of figure 2. This filling with random data makes it difficult for an
attack to chance the measurement routines, because to make that in a way that it is not perceived in a
future audit would require additional memory. Because the unused memory space has non-negligible
data (they are part of the memory content to be audited), they cannot be simply overwritten, thus
making it difficult for software change attacks.
An attacker may, however, use some sort of compression on the existing data in the unused memory
area and perform decompression in real time at the time the integrity check is invoked. Thus, the
attacker will obtain the additional memory space, necessary for his attack to occur successfully. Thus, in
order to minimize the risk of a compression attack, the unused memory area must be filled with random
high-scatter data. One suggestion for random number source generated with great dispersion are those
provided by random.org. If a pseudorandom number generator is chosen to fill the unoccupied memory,
the generator must meet the requirements of standard SP 800-22.
In the case of a U-type computer, the documentation specifies an identifier for the operating system and
for each system component that has been modified or added, such as drivers. This identifier could be,
for example, the version of the Linux distribution or the Windows 7 Service Pack number.
The documentation should indicate in the source code the location of the routines responsible for the
creation and access to the software identifier (eg, file, class, method, routine, etc.).
If the instrument uses the communication protocol described in NIT-Sinst-020 and makes use of the
challenge and response integrity check tool described in Annex A of NIT-Sinst-020, it will not be
necessary for the applicant to implement an integrity check. In this case it should be informed:
Otherwise, the documentation shall describe the method of verifying the integrity of the legally relevant
software on the instrument and the procedure for performing it. As stated in item 8.5.1 of NIT-Sinst-003,
the integrity check tool should be included in the documentation package as well as its installation
manual, operation and description of the communication protocol used. The description of
implemented integrity checking algorithms and mechanisms should be provided.
The documentation should indicate in the source code the location of the routines responsible for the
integrity checking (eg, file, class, method, routine, etc.).
It should describe the algorithm through flowchart, highlighting inputs and outputs.
Explain the current sensor type, measurement shape (two or four quadrants) and record form
(unidirectional recorder, bi-directional recorder or ratchet recorder). Clearly relate the form of
measurement and registration in the implementation, pointing out the functionalities and
computational resources used, for example, if there is a measurement unit for energy in the
microcontroller and how it works. Note the numerical errors associated with the implementation of the
measurement algorithm used.
The documentation should indicate in the source code the location of the measurement algorithm (eg,
file, class, method, routine, etc.).
The documentation should contain a list of all the commands, explaining the functionality of each of
them and an explicit statement that all the commands are contemplated in the presented list.
Note: For the declaration of completeness, it suffices a clear sentence in the documentation that all the
commands implemented in the software are described in the documentation.
The behavior of the instrument when receiving each command should be described, preferably using
state diagram and activity diagram associating the corresponding routines in the source code.
Display test case report for each of the commands. This report shall contain the procedures used to test
each command as well as the description of the tests performed.
The documentation should describe the access controls when it is possible to change metrologically
relevant parameters with the use of communication interfaces. Preferably, the cryptographic algorithms
for access control must obey the SP 800-57, part 1 standard.
The documentation should indicate in the source code the location of the routines responsible for
treating the data interfaces.
The documentation should show how the instrument verifies the integrity of its program memory
against accidental changes, measurement data against accidental changes and legally relevant
parameters against accidental changes.
When accidental changes occur, the documentation should state the error codes generated and the
handling of those errors.
The documentation should indicate the source code routines responsible for dealing with protections
against accidental changes.
Protection measures against improper or fraudulent use of the instrument, including mechanical,
electronic and/or cryptographic protection devices shall be described. The cryptographic algorithms
used must be in accordance with SP 800-57 Part 1.
Legally relevant software and parameters must be protected against inadmissible or unauthorized
modifications. The documentation should describe the protection against physical modifications to the
instrument, such as those caused by improper exchange of memory units. If the instrument accepts
software load, only loads of software signed by Inmetro must be authorized.
The documentation should indicate the source code’s routines responsible for dealing with the
protection against intentional changes.
It should be presented in the documentation a table informing, for each parameter, the function in the
source code that allows its change, nominal value, variation range and storage location, like Table 1.
Source: Sinst
Describe the protection methods used so that they are protected against unauthorized modification.
Describe the procedures for changing parameters. For seasonal fare meters and white tariffs, if an
authentication scheme is used, the authentication requirements must comply with the provisions of
item 8.8 of NIT-Sinst-019, which deals with the need for validity in the model approval regulations for
the meters if the authentication scheme adopted is not strong enough.
Description of the Registration Procedure for Alteration of Relevant Metrological Parameters. Describe
the format of all parameter change records by indicating the meaning of each field of the records. If
more appropriate, point to it at the time the test case is described. Records should not contain sensitive
information, such as the cryptographic key used by the devices. The record, depending on the event
generated, should indicate who made the access, when that event occurred and what the event caused
in the system’s behavior. Describe the mechanism for retrieving records. Identify the storage capacity of
each record and timing.
Describe the parameter change registration procedure of the stored data’s format.
Describe how the parameters are referenced in the audit log and how they can be viewed.
Provide assurances that the components that store legally relevant audit records, data and parameters
are physically and logically tamper-evident.
The records in the Registry of Changes of Relevant Metrological Parameters shall contain at least the
parameter identification, the value before and after the change and the timestamp.
Document the list of faults that are detectable, their detection algorithms and reactions triggered. The
instrument shall not perform measurement while in the fault state.
Indicate in the source code the location of the routines responsible for detecting and handling the faults.
Explain in the documentation how these routines are triggered (interrupts, watchdogs, etc.).
7.2.10. Software Validation
Item 7.2.10 clarifies the requirement 3.1.10.1 of Administrative Rule nº586 of November 1 st, 2012.
Describe the test cases used to validate the measuring instrument’s software. Assemble a table,
according to table 2, for each test case.
Item Description
Title Test case’s title.
Author Name of the one responsible for executing the test.
Summary Contains a description of the test case, describing the test’s
purpose or objective as well as its scope.
Pre-Conditions For each execution condition, it describes the mandatory state of
the system before the start of the test.
Inputs For each execution condition, it lists a set of the specific stimuli to
be applied during the test. In general, they are called test entries
and include the objects or interaction fields and the specific data
values entered during the execution of this test case.
Procedure For the test’s execution, these are the actions that the user must
perform so that the system can comply with what will be tested.
Expected It is the resulting state or observable conditions expected as a result
Results of the test run. Note that this may include both positive and
negative responses (such as error conditions and failures).
Results Found It is the actual result of the test run. Note that this includes both
positive and negative outcomes.
Evidence of the Set of information that evidences the result described in the
Results Found previous item, such as: screen printscreen of the system containing
the result, photographic record or video recording, system log file,
block of data trafficked in response, etc.
Post-Conditions For each execution condition, it describes the state to which the
system should return to allow subsequent tests to run. Report only
in exceptional cases.
Source: Sinst
Separation of legally relevant parties. These requirements must be met when the instrument has
legally irrelevant software and legally relevant software. This approach allows the applicant to
maintain legally non-relevant software in the instrument and can be changed without going through
a model modification;
Transmission of data through the communication network. When the instrument uses
communication network within the legally relevant chain;
Loading legally relevant software. When it is possible to change the legally relevant software
shipped in the instrument without breaking the main sealing;
Architectures based on digital signature. When the system uses digital signature to ensure
authenticity and irrefutability.
Software-controlled measuring instruments can have complex functionalities and contain modules that
are legally relevant and modules that are not. Software separation is a methodology that allows the
applicant to easily modify software that is not legally relevant.
The documentation should describe the design of the software and/or hardware separation in detail.
The use of block diagram corroborates in the understanding of software separation. Description and
identification of software modules (programs, subroutines, libraries) and hardware (electronic boards,
components, transducers) that perform legally relevant functions or contain legally relevant data.
All the program units (subroutines, procedures, functions, classes) and, in the case of high-level
separation, all the programs and libraries that contribute to 1) the calculation of value’s measurements
or that have an impact on it and for 2) auxiliary functions such as data display, data security, data
storage, software identification, software loading, transmission or storage of data, checking or storage of
received data.
Legally relevant software belongs to all variables, temporary files and parameters that have an impact
on legally relevant measurement values or functions, or data. If legally relevant software runs on an
operating system, that operating system is also legally relevant. Other program units and data or
parameters not mentioned above make up the legally non-relevant software. Modifications to the
legally non-relevant part are permitted provided that the software separation requirements are
observed.
Additional information generated by software that is not legally relevant can only be displayed (or
printed) if it cannot be confused with the information that originates from the legally relevant part.
Description of the separation interface, or protective software interface, between legally relevant and
non-legally relevant parties (including descriptions of functions, data domains, communication protocols
and data bus). Any interactions and data flows should not inadvertently influence legally relevant
software.
The documentation shall present the communication protocol in detail and a complete list containing
the description and functionality of the software and/or hardware separation interface commands. As a
complement to the specified list of commands, a declaration of completeness of the commands used
through the instrument interfaces should be presented.
Note – the declaration of completeness corresponds to a statement by the applicant stating that only
the commands described in the documentation have influence on the measuring instrument or system
being analyzed.
If the legally relevant software and the legally non-relevant software use the same computational
resources, the documentation shall describe how the necessary availability for the correct execution of
legally relevant software is guaranteed: interrupt hierarchy, time schedule of software tasks, time limit
for legally non-relevant tasks.
For each command listed, indicate the respective part of the software’s source code that handles the
command.
7.3.3. Transmission of Data Over a Communication Network
Item 7.3.3 clarifies requirement 3.2.3.1 of Administrative Rule nº586 of November 1 st, 2012.
The documentation should describe the mechanisms that guarantee the authenticity of the information
trafficked between the modules. Constructive solutions, such as sealing and logic, like the use of
encryption tools such as HMAC, can be used to ensure authenticity.
The documentation should describe the mechanisms that guarantee the integrity of the information
trafficked between the modules. For example, with the use of error detection tools (CRC, checksums,
cryptographic hash functions, etc.) that in turn change the state of the instrument to handle the
detected error. Other approaches, such as the use of error correction algorithms, are also possible.
Document the network topology, the technology used for the connections, the network interfaces and
their respective controllers, the operation of rubs, bridges, switches, communication protocol, etc.
The documentation should describe the communication protocol in detail. If a known protocol is used,
such as TCP/IP, the documentation should describe how the instrument makes use of the protocol to
transmit the data.
The mechanisms used to discard or reconstruct corrupted data must be described in the documentation,
as well as the measurement is protected against delays arising from communication and protection
against interruption of transmission.
The respective security measures must be detailed to prevent intrusion into the internal network.
Constructive solutions such as sealing, and logical use such as strong authentication tools can be used to
protect the communication network.
The documentation should describe the mechanisms for the confidentiality of cryptographic keys if they
are used for data transmission.
The documentation should describe the loading procedure of legally relevant software.
The documentation shall describe the means by which it is ensured that the legally relevant software
has been evaluated and approved by Inmetro. The process for authenticity of the remotely loaded
software passes through the use of a public key provided by Inmetro as specified in item 10 of NIT-Sinst-
003, and by a digital signature of the software-approved software binary. The memorial should describe
which component of the measuring instrument verifies the digital signature of new software (signed
with Inmetro’s private key) from an auxiliary memory and, attested to authenticity, replaces the old
software with the new one and loads the latter during the boot process.
Describe load protection measures and unauthorized modifications of legally relevant software and
behavior in the event of a software load failure and how the instrument signals the error.
Describe hardware support. (Example: there is an additional buffer for temporary storage of
downloaded software).
Description of the software load registration procedure and data format. Describe the format of all
software load records pointing to the meaning of each field of the records. If more appropriate, point to
it at the time the test case is described. Records should not contain sensitive information, such as the
cryptographic key used by the devices. The record, depending on the generated event, should indicate
who made the access, when that event occurred and what the event caused in the behavior of the
system. Describe the mechanism for retrieving records. Identify the storage capacity of each record and
timing.
Description of the procedure for making available and publishing legally relevant software load records
and description of the physical and logical tampering of components that store legally relevant software
load records.
For seasonal fare meters and white tariffs, if an authentication scheme is used, the authentication
requirements must comply with the provisions of item 9.3 of NIT-Sinst-019, which deals with the need
for validity in the model approval regulations for the meters if the authentication scheme adopted is not
strong enough.
Indicate in the source code the location of the routines responsible for loading the software.
Meters whose input quantities are digitally signed only require the delivery of the source code that
includes all states and system activities from the initialization to where the digital signature occurs. All
communication interface source codes that cause a change in the instrument’s state before the digital
signature must also be delivered.
The documentation must be explicit about the commands that cause change in the state of the
instrument before the digital signature. For example, a command that changes the input quantities, that
allow to change the order of the measurement or to act in the process of digital signature of these
quantities. These commands cannot allow undue behavior of the measurement system. For example, a
combination of the use of these commands should not allow the introduction of a systematic error into
one of the input quantities.
The applicant shall provide a tool so that it is possible to reconstruct the measurement from the input
quantities. The tool should also allow to evaluate the accuracy of the measurement algorithm. The
accuracy of the measurement algorithm must be stated in the documentation.
If the instrument loads software, it is necessary to present the source code associated with the routines
that allow loading and all legally relevant software must be signed by Inmetro.
All digitally signed input quantities shall be treated as part of the legally and metrologically complete
measurement result. There must be a way to verify the digital signature of the measurement.
The management of these keys should be detailed to ensure their safety. The security specification of
the components that store cryptographic keys must be provided.
Describe in detail the main task of each module’s software using an activity diagram. The main task is
that performed when the system is initialized by the main function. A task is characterized by a single
flow of sequential control within the running software (process). Figure 2 shows a simplified activity
diagram for the main task.
Describe the modules/libraries/functions that are used by the main task, describe the initial state and
the stopping conditions (if any) and present a time diagram.
The documentation should present test cases for the dynamic behavior of the instrument confirming the
correct operation of the time diagram and the respective changes when the error situations are
provoked.
Documentation should provide calculations that demonstrate the ability to share hardware resources
that have shared use, such as hubs, communication networks, switches, and so on.
The documentation should present test cases of instrument performance, such as stress level, load test,
containment test and performance profile test.
Approval Flow
Name Role
Carlos Eduardo Cardoso Galhardo Sinst’s Quality Coordinator
Prepared
by:
Fabiano O Leitão Technologist Researcher in Metrology and Quality
Verified Juliana Wilm Sinst’s Intern
by:
Amsterdam de J.S.M. de Mendonça Dimel’s Quality Coordinator
Approved
Bruno Erthal Sinst’s Supervisor
by: