mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-13 20:06:24 +08:00
SM4/CTR
This commit is contained in:
27
crypto/byteorder.h
Normal file
27
crypto/byteorder.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef HEADER_BYTEORDER_H
|
||||
#define HEADER_BYTEORDER_H
|
||||
|
||||
|
||||
#ifdef CPU_BIGENDIAN
|
||||
|
||||
#define cpu_to_be16(v) (v)
|
||||
#define cpu_to_be32(v) (v)
|
||||
#define be16_to_cpu(v) (v)
|
||||
#define be32_to_cpu(v) (v)
|
||||
|
||||
#else
|
||||
|
||||
#define cpu_to_le16(v) (v)
|
||||
#define cpu_to_le32(v) (v)
|
||||
#define le16_to_cpu(v) (v)
|
||||
#define le32_to_cpu(v) (v)
|
||||
|
||||
#define cpu_to_be16(v) (((v)<< 8) | ((v)>>8))
|
||||
#define cpu_to_be32(v) (((v)>>24) | (((v)>>8)&0xff00) | (((v)<<8)&0xff0000) | ((v)<<24))
|
||||
#define be16_to_cpu(v) cpu_to_be16(v)
|
||||
#define be32_to_cpu(v) cpu_to_be32(v)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user