CN104065472B - Meter encryption method - Google Patents

Meter encryption method Download PDF

Info

Publication number
CN104065472B
CN104065472B CN201410290537.6A CN201410290537A CN104065472B CN 104065472 B CN104065472 B CN 104065472B CN 201410290537 A CN201410290537 A CN 201410290537A CN 104065472 B CN104065472 B CN 104065472B
Authority
CN
China
Prior art keywords
data
encryption
sequence number
nibble
substitution
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201410290537.6A
Other languages
Chinese (zh)
Other versions
CN104065472A (en
Inventor
周峋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
SHANGHAI XIELIN ELECTRONIC CO Ltd
Original Assignee
SHANGHAI XIELIN ELECTRONIC CO Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by SHANGHAI XIELIN ELECTRONIC CO Ltd filed Critical SHANGHAI XIELIN ELECTRONIC CO Ltd
Priority to CN201410290537.6A priority Critical patent/CN104065472B/en
Publication of CN104065472A publication Critical patent/CN104065472A/en
Application granted granted Critical
Publication of CN104065472B publication Critical patent/CN104065472B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention relates to a meter encryption method. A 64-bit key is used to encrypt a 64-bit plaintext to obtain a 64-bit cipher text. The method is characterized by comprising a step of defining at least two encryption substitution tables and an encryption permutation table and generating a 64-bit cipher key, a step of carrying out data substitution on the 64-bit plaintext by using the combination of the 64-bit cipher key and the encryption substitution tables to obtain substituted 64-bit data, a step of carrying out data permutation on data corresponding to each bit sequence number in the substituted 64-bit data by using the encrypted permutation table, and a step of obtaining the 64-bit cipher text. The invention discloses a meter data encryption scheme, in the condition of not increasing meter cost and only slightly expanding a DL/T645 protocol, and the safety of a meter can be greatly improved only through the slight modification of meter software. According to the encryption method, encrypted data is divided into 8-byte data blocks for respective encryption, an 8-byte cipher key is outputted after the encryption of each data block, and the strength of encryption method is about same with that of a DES.

Description

Ammeter encryption method
Technical field
The present invention relates to a kind of method that plaintext to multifunctional electric energy meter transmission is encrypted.
Background technology
The communication protocol that at present country's multifunctional electric energy meter is adopted is DL/T645-2007, and the stipulations are succinctly efficient, shortcoming It is that password is transmitted with plain code when data are transmitted, it is easy to be monitored to, the safety of multifunctional electric energy meter is relatively low.For this purpose, state's net Method with ESAM chips are added, has expanded DL/T645-2007 stipulations, and although the safety of multifunctional electric energy meter is improved, But the cost of multifunctional electric energy meter is the increase in, and it is too big to the modification amplitude of stipulations so that and multifunctional electric energy meter is developed, made Difficulty increases.
The content of the invention
The technical problem to be solved in the present invention is that the safety of multifunctional electric energy meter is improved on the basis of cost is not increased.
In order to solve above-mentioned technical problem, the technical scheme is that there is provided a kind of ammeter encryption method, adopt 64 Position key is encrypted to 64 plaintexts, to obtain 64 ciphertexts, it is characterised in that step is:
Step 1, at least two encryption substitution tables of definition and a keyed permutation table, generate 64 keys, wherein;Encryption is replaced The position sequence number for changing table is arranged to 15 by 0, is that any one encrypted in each the sequence number distribution 0~15 in substitution table is whole Number, the value of different positions sequence number distribution is differed in same encryption substitution table, identical bits sequence number distribution in difference encryption substitution table Value is differed;
The position sequence number of keyed permutation table is arranged to 63, in being each the sequence number distribution 0~63 in keyed permutation table by 0 Any one integer, the value of different position sequence numbers distribution differs;
Step 2,64 plaintexts are carried out using 64 key combining encryption substitution tables after data are replaced 64 Position data, its step is:
Step 2.1, the nibble that 64 keys and 64 plaintexts are divided into 16 nibbles, 64 keys and 64 plaintexts Sequence number is arranged to 15 by 0;
Step 2.2, from the nibble and the half-word of 64 plaintext nibble serial numbers 0 of 64 key nibble serial numbers 0 Section begins, and using encryption substitution table the data of 64 plaintext each nibbles are replaced successively, wherein, nibble sequence number in 64 plaintexts Nibble data replacement method for i is:
Judge in 64 keys in the nibble data of nibble serial number i at least value of a data, different values pair Different encryption substitution tables are answered, the encryption substitution table corresponding to the value of current data is found, by nibble sequence number in 64 plaintexts For i nibble data value as current crypto substitution table position sequence number, with current crypto substitution table with the sequence number pair The data answered replace the nibble data of nibble serial number i in 64 plaintexts;
Step 3, using keyed permutation table to replacement after 64 data in data difference corresponding to each sequence number Carry out 64 data after data are replaced, to replacement after 64 data position sequence number j corresponding to data carry out The step of displacement is:
Position sequence number j of 64 data after using replacement finds as the position sequence number of keyed permutation table in keyed permutation table Position sequence number j corresponding to data value, if the value of the data be k, then by replacement after 64 data middle position sequence numbers j corresponding to Position sequence number k of 64 data of the data distribution to after replacing;
Step 4, obtain 64 ciphertexts.
Preferably, before the step 2.1 and after the step 1, or 64 keys are taken into complement code, or will 64 key rotations are moved to left or ring shift right at least, or first 64 keys are taken after complement code, then will be described 64 key rotations are moved to left or ring shift right at least.
Preferably, also have after the step 3 and before the step 4:Step A, 64 keys that step 1 is obtained are followed Ring move to left or ring shift right at least after, return to step 2, iteration execution step 2 to step A at least 2 times.
The present invention proposes an ammeter data encipherment scheme, is not increasing ammeter cost and is only slightly extending DL/T645 rule In the case of about, the software of ammeter only need to be modified slightly, and can greatly improve the safety of ammeter.The encryption method will encrypt number Encrypt respectively according to the data block for being divided into 8 bytes, 8 byte cryptograms are exported after each encryption of blocks of data, the encryption method is strong with DES Degree is suitable.
Description of the drawings
A kind of flow chart of ammeter encryption method that Fig. 1 is provided for the present invention;
Fig. 2 is the flow chart that data are replaced in ammeter encryption method;
Fig. 3 is data displacement schematic diagram in ammeter encryption method;
Fig. 4 moves to left a schematic diagram for key rotation;
Fig. 5 is decryption schematic flow sheet;
Fig. 6 is data displacement schematic diagram in decryption flow process;
Fig. 7 replaces schematic diagram for data in decryption flow process.
Specific embodiment
To become apparent the present invention, hereby with preferred embodiment, and accompanying drawing is coordinated to be described in detail below.
Before the ammeter encryption method for implementing the present invention, original 645-2007 stipulations are observed, it is found that write operation is all that password adds Operator's code, totally 8 bytes, the data block (ciphertext after encryption is also 8 bytes) of exactly one encryption.By this 8 The data of byte redefine as follows:
1st~4 byte:Data Identification DI;
5th~6 byte:The CRC check code of data is set;
7th byte:First byte mailing address;
8th byte:
bit7-6:00-- data are not encrypted, and 01-- only encrypts first packet;
10-- only encrypts front 2 packets, all data encryptions of 11--;
bit5-3:The zero padding number (data length is 8 multiple after zero padding) of data during encryption;
bit2-0:Random number.
Ammeter is received after correct message, if writing data message, then uses secret key decryption.Front 4 byte of plaintext with The Data Identification DI of message compares, and the CRC check code of the setting data that the 5th~6 byte of plaintext is calculated with ammeter compares, in plain text The 7th byte compare with first byte mailing address, if there is difference, be considered as password wrong.
It is to ensure that the setting password to different pieces of information is different (class that 1st~4 byte is defined as Data Identification DI Like the dispersion factor of key).The CRC check code that 5th~6 byte is defined as arranging data is to prevent altered data content. It is to make the message only effective to this ammeter as far as possible that 7th byte is defined as first byte mailing address.8th byte packet contains random number It is to increase the difficulty of code breaking.
If the bit7-6 of the 8th byte is not all zero, data also use key encryption and decryption, and every 8 byte is a data Packet, can select as needed to first packet, front 2 packets or all data encryptions.If data during encryption 8 bytes are discontented with packet, then must first zero padding re-encrypt, the data length after decryption to deduct zero padding byte number (the 8th byte Bit5-3 is specified, 0~7).
Requirement is reset, electricity resets, event resets and breaker tripping and closing control command, the 1st~4 byte replaces number with the second in century According to mark DI, after ammeter decryption, the second in century is compared with the time of ammeter, such as time difference is more than 300 seconds, then be considered as close Code is wrong.
With reference to Fig. 1, the invention provides 64 plaintexts are encrypted by a kind of ammeter encryption method using 64 keys, To obtain 64 ciphertexts, its step is:
Step 1, two encryption substitution tables of definition and a keyed permutation table, generate 64 keys, wherein;Encryption substitution table Position sequence number arranged to 15 by 0, be to encrypt any one integer in each sequence number distribution 0~15 in substitution table, together The value of different positions sequence number distribution is differed in one encryption substitution table, the values of identical bits sequence number distribution not phase in difference encryption substitution tables Together, in the present embodiment, the preferred example of two encryption substitution tables of generation is as shown in table 1.
Encryption substitution table 1 14,10,7,9,12,3,2,5,13,0,15, Isosorbide-5-Nitrae, 8,6,11
Encryption substitution table 2 12,8,2,13,7,6,1,3,11,5,9,15,0,4,10,14
Table 1
The position sequence number of keyed permutation table is arranged to 63, in being each the sequence number distribution 0~63 in keyed permutation table by 0 Any one integer, the value of different position sequence numbers distribution differs, in the present embodiment, the keyed permutation table preferred example of generation As shown in table 2.
Table 2
Step 2, the complement code for taking 64 keys.
Step 3,64 key rotations that step 2 is obtained are moved to right into 12.The digit of 64 key rotation movements and selection Ring shift right or ring shift left, are what those skilled in the art can determine as needed.
Step 4, the 64 key combining encryption substitution tables obtained using step 3 are carried out data replacement to 64 plaintexts and are obtained 64 data after replacement, its step is:
Step 4.1, the nibble that 64 keys and 64 plaintexts are divided into 16 nibbles, 64 keys and 64 plaintexts Sequence number is arranged to 15 by 0;
Step 4.2, from the nibble and the half-word of 64 plaintext nibble serial numbers 0 of 64 key nibble serial numbers 0 Section begins, and using encryption substitution table the data of 64 plaintext each nibbles are replaced successively, wherein, nibble sequence number in 64 plaintexts Nibble data replacement method for i is:
Judge in 64 keys in the nibble data of nibble serial number i at least value of a data, different values pair Different encryption substitution tables are answered, according to a data, then from two encryption substitution tables, one encryption of the correspondence of numerical value 0 is replaced Table, numerical value 1 then corresponds to other encryption substitution table, according to two bits, then from four encryption substitution tables, numerical value 0-3 The different encryption substitution table of correspondence.The encryption substitution table corresponding to the value of current data is found, by nibble sequence in 64 plaintexts Number for i nibble data value as current crypto substitution table position sequence number, with current crypto substitution table with the sequence number Corresponding data replace the nibble data of nibble serial number i in 64 plaintexts.
With reference to Fig. 2, for two encryption substitution tables in the table 1 that obtains in the present embodiment, then data are replaced flow process and are:
Step 4A.1, the nibble for taking 64 key nibble sequence numbers i and 64 plaintext nibble sequence numbers i are 0;
Step 4A.2, judge whether the 3rd of nibble of 64 key nibble sequence numbers i is 0, if so, then 64 it is bright The nibble of literary nibble sequence number i is replaced with the corresponding data of middle position sequence number i of encryption substitution table 1 in table 1;If it is not, then 64 The nibble of plaintext nibble sequence number i is replaced with the corresponding data of middle position sequence number i of encryption substitution table 2 in table 1;
Step 4A.3, i=i+1;
Step 4A.4, return to step 4A.2 are until repeated 16 times.
Step 5, combine Fig. 3, using encryption substitution table to replacement after 64 data in corresponding to each sequence number Data carry out respectively 64 data after data are replaced, to replacement after 64 data position sequence number j corresponding to The step of data enter line replacement be:
Position sequence number j of 64 data after using replacement finds as the position sequence number of keyed permutation table in keyed permutation table Position sequence number j corresponding to data value, if the value of the data be k, then by replacement after 64 data middle position sequence numbers j corresponding to Position sequence number k of 64 data of the data distribution to after replacing.
Step 6, combine Fig. 4,64 key rotations move to left one after return to step 4, until by step 4 to step 5 iteration Perform 16 times.The digit and selection ring shift right or ring shift left of 64 key rotation movements, the iteration of step 4 to step 5 is held Places number, is what those skilled in the art can determine as needed.
Step 7, obtain 64 ciphertexts.
With the decryption method corresponding to ammeter encryption method mentioned above as shown in figure 5, its step is;
Step 1, the decryption substitution tables corresponding with substitution table is encrypted of definition two and a solution corresponding with keyed permutation table Close permutation table, as shown in table 3, decryption permutation table is as shown in table 4 for decryption substitution table.
Decryption substitution table 1 12,6,2,7,13,9,5,4,1,10,14,8,0,3,15,11
Decryption substitution table 2 9,11,6,5,12,7,14,2,13,3,1,15,4,8,0,10
Table 3
Table 4
Step 2,6 are combined, the data corresponding to each sequence number in 64 ciphertexts are entered respectively using decryption permutation table Row data replaced after 64 data, the step of enter line replacement to the data corresponding to position sequence number j of 64 ciphertexts For:
Using position sequence number j of 64 ciphertexts as the position sequence number of decryption permutation table, in decryption permutation table a sequence number j institute is found The value of corresponding data, if the value of the data is k, then by the data distribution corresponding to 64 ciphertext middle position sequence numbers j to after replacing 64 data position sequence number k.
Step 3, using 64 key combining encryption substitution tables to displacement after 64 data carry out data and replaced 64 data after changing, with reference to Fig. 7, its step is:
Step 3.1, the nibble for taking 64 key nibble sequence numbers i and displacement after 64 data nibbles sequence numbers i be 0;
Step 3.2, judge whether the 3rd of nibble of 64 key nibble sequence numbers i is 0, after if so, then replacing The nibble of 64 data nibbles sequence numbers i is replaced with the corresponding data of middle position sequence number i of decryption substitution table 1 in table 3;If it is not, The decryption substitution table 2 middle position sequence number i corresponding data of the nibble in table 3 of 64 data nibbles sequence numbers i after then replacing Replace;
Step 3.3, i=i+1;
Step 3.4, return to step 3.2 are until repeated 16 times.
Step 4,64 key rotations move to left one after return to step 2, until by step 2 to step 4 iteration perform 16 times.

Claims (3)

1. 64 plaintexts are encrypted by a kind of ammeter encryption method using 64 keys, and to obtain 64 ciphertexts, its feature exists In step is:
Step 1, at least two encryption substitution tables of definition and a keyed permutation table, generate 64 keys, wherein;Encryption substitution table Position sequence number arranged to 15 by 0, be to encrypt any one integer in each sequence number distribution 0~15 in substitution table, together The value of different positions sequence number distribution is differed in one encryption substitution table, the values of identical bits sequence number distribution not phase in difference encryption substitution tables Together;
The position sequence number of keyed permutation table is arranged to 63 by 0, is appointing in each the sequence number distribution 0~63 in keyed permutation table One integer of meaning, the value of different position sequence number distribution is differed;
Step 2,64 digits after data are replaced are carried out to 64 plaintexts using 64 key combining encryption substitution tables According to its step is:
Step 2.1, the nibble sequence number that 64 keys and 64 plaintexts are divided into 16 nibbles, 64 keys and 64 plaintexts Arranged to 15 by 0;
Step 2.2, the nibble from 64 key nibble serial numbers 0 and the nibble beginning of 64 plaintext nibble serial numbers 0, The data of 64 plaintext each nibbles are replaced successively using encryption substitution table, wherein, nibble serial number i in 64 plaintexts Nibble data replacement method is:
Judge in 64 keys in the nibble data of nibble serial number i at least value of a data, different values correspondences are not Same encryption substitution table, finds the encryption substitution table corresponding to the value of current data, according to a data, is then added from two Close substitution table, one encryption substitution table of the correspondence of numerical value 0, numerical value 1 then corresponds to other encryption substitution table, according to double figures According to then from four encryption substitution tables, the different encryption substitution table of numerical value 0-3 correspondences, by nibble serial number i in 64 plaintexts Nibble data value as current crypto substitution table position sequence number, with corresponding with the sequence number in current crypto substitution table Data replace the nibble data of nibble serial number i in 64 plaintexts;
Step 3, using keyed permutation table to replacement after 64 data in data corresponding to each sequence number carry out respectively Data replaced after 64 data, to replacement after 64 data position sequence number j corresponding to data enter line replacement The step of be:
Position sequence number j of 64 data after using replacement finds a sequence as the position sequence number of keyed permutation table in keyed permutation table The value of the data corresponding to number j, if the value of the data is k, then by replacement after 64 data middle position sequence numbers j corresponding to data Position sequence number k of 64 data distributed to displacement;
Step 4, obtain 64 ciphertexts.
2. a kind of ammeter encryption method as claimed in claim 1, it is characterised in that:Before the step 2.1 and in the step After rapid 1, or 64 keys are taken into complement code, or 64 key rotations are moved to left or ring shift right at least, Or first 64 keys are taken after complement code, then 64 key rotations are moved to left or ring shift right at least.
3. a kind of ammeter encryption method as claimed in claim 1, it is characterised in that:After the step 3 and in the step 4 It is front to also have:Step A, by 64 key rotations that step 1 is obtained move to left or ring shift right at least after, return to step 2, iteration Execution step 2 is to step A at least 2 times.
CN201410290537.6A 2014-06-25 2014-06-25 Meter encryption method Active CN104065472B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410290537.6A CN104065472B (en) 2014-06-25 2014-06-25 Meter encryption method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410290537.6A CN104065472B (en) 2014-06-25 2014-06-25 Meter encryption method

Publications (2)

Publication Number Publication Date
CN104065472A CN104065472A (en) 2014-09-24
CN104065472B true CN104065472B (en) 2017-04-26

Family

ID=51553017

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410290537.6A Active CN104065472B (en) 2014-06-25 2014-06-25 Meter encryption method

Country Status (1)

Country Link
CN (1) CN104065472B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113595717B (en) * 2020-04-30 2023-10-17 比亚迪股份有限公司 ECB mode packet encryption method and decryption method, control device and vehicle

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108075890A (en) * 2016-11-16 2018-05-25 中兴通讯股份有限公司 Data sending terminal, data receiver, data transmission method and system
CN108920131B (en) * 2018-04-27 2022-03-22 北京奇艺世纪科技有限公司 Data processing method and device
CN109039586B (en) * 2018-08-17 2021-06-29 贵州大学 Recoverable reserved digital type lightweight desensitization method

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102377566A (en) * 2010-08-11 2012-03-14 北京融通高科科技发展有限公司 Security processing device and system for electric meter data
CN102903226A (en) * 2012-10-18 2013-01-30 杭州海兴电力科技股份有限公司 Data transmission method for communication of intelligent electric meters

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102377566A (en) * 2010-08-11 2012-03-14 北京融通高科科技发展有限公司 Security processing device and system for electric meter data
CN102903226A (en) * 2012-10-18 2013-01-30 杭州海兴电力科技股份有限公司 Data transmission method for communication of intelligent electric meters

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
加密算法在智能抄表系统中的应用;程峰等;《CNKI》;20040425;全文 *
智能电表通信模型与密钥管理方法研究;陈锦山;《万方学位论文》;20121130;全文 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113595717B (en) * 2020-04-30 2023-10-17 比亚迪股份有限公司 ECB mode packet encryption method and decryption method, control device and vehicle

Also Published As

Publication number Publication date
CN104065472A (en) 2014-09-24

Similar Documents

Publication Publication Date Title
CN104410616B (en) data encryption, decryption, transmission method and system
CN102710415B (en) Method and table look-up device for encrypting and decrypting data by using symmetric cryptographic algorithm
NO333209B1 (en) Block cryptogram apparatus using auxiliary transformation
CN106656475A (en) Novel symmetric key algorithm for high speed encryption
CN104065474B (en) Novel low-resource efficient lightweight Surge block cipher implementation method
CN104065472B (en) Meter encryption method
CN1972237A (en) VPN system based on dynamic encryption algorithm
CN103905187A (en) Network communication encryption method based on contents
Pimpale et al. Modifications to aes algorithm for complex encryption
CN107947916B (en) Integrated encryption and decryption module based on DES algorithm
CN103580851A (en) Information encryption and decryption method
CN109218013A (en) Cover the binary data communication encryption method on plaintext symbol boundary
CN105916141A (en) Self-synchronizing realization system and self-synchronizing realization method for Zu Chongzhi encryption and decryption algorithm
CN107070637A (en) A kind of data encryption/decryption method of overlapping packet
Tang et al. A one-time pad encryption algorithm based on one-way hash and conventional block cipher
CN107846422A (en) A kind of configuration file ciphered compressed of gateway and the method for decryption decompression
CN109257161A (en) Binary data encrypts equipment and encryption method
Mohan et al. Revised aes and its modes of operation
Shinde et al. A review of various encryption techniques
KR101428665B1 (en) Security system and method for using aes-otp
CN106788968A (en) It is applied to the implementation method of the security coprocessor of WIA-PA agreements
CN102665202B (en) Secure coprocessor circuit structure applied to ZigBee protocol and control method thereof
CN110247754A (en) A kind of implementation method and device of block cipher FBC
Azzawi Enhancing the encryption process of advanced encryption standard (AES) by using proposed algorithm to generate S-Box
CN108616351A (en) A kind of full dynamic encryption decryption method and encrypting and decrypting device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant