Commit graph zephyr/drivers/crypto/crypto_ataes132a_priv.h
Author SHA1 Message Date
Flavio Ceolin
ef10214f20 crypto: ataes132a: Fix counter reg
Use shift operand instead of wrong boolean operator
to access (16) counter addresses [0xf100 - 0xf17f]
properly.

Signed-off-by: Flavio Ceolin <flavio@hubble.com>
2026-07-12 20:01:09 -04:00
Flavio Ceolin
bd2b24cd7a crypto: ataes132a: Fix zone config reg
Use shift operand instead of wrong boolean operator
to access (16) zone config addresses [0xf0d0 - 0xf0ff]
properly.

Signed-off-by: Flavio Ceolin <flavio@hubble.com>
2026-07-12 20:01:09 -04:00
Flavio Ceolin
d0e0dff28f crypto: ataes132a: Fix counter config reg
Use shift operand instead of wrong boolean operator
to access (16) counter config addresses [0xf060 - 0xf07f]
properly.

Signed-off-by: Flavio Ceolin <flavio@hubble.com>
2026-07-12 20:01:09 -04:00
Flavio Ceolin
583c64670e crypto: ataes132a: Remove unused field in device_data
All I2C access in crypto_ataes132a goes through
ataes132a_device_config.  The i2c field in ataes132a_device_data
field is never written or read.

Signed-off-by: Flavio Ceolin <flavio@hubble.com>
2026-07-12 20:01:09 -04:00
Flavio Ceolin
bf54b7c26e crypto: ataes132a: Fix key config reg
Table 14-1. ATAES132A Configuration Memory Map says
that key config spans from 0xf080 to 0xf0bf for a total of
16 keys. (0xF080 + (keyid < 2)) uses the boolean operator
instead of bit shift operator and produces values.

Signed-off-by: Flavio Ceolin <flavio@hubble.com>
2026-07-12 20:01:09 -04:00
Flavio Ceolin
dd705f51a8 crypto: ataes132a: Fix invalid bit mask
EncryptOK is represented by bits 1 and 2 and the proper
mask is (BIT(1) | BIT(2)) and not (BIT(1) & BIT(2)) that
evaluates always to 0b00.

Signed-off-by: Flavio Ceolin <flavio@hubble.com>
2026-07-12 20:01:09 -04:00
Flavio Ceolin
b0cab05152 crypto: ataes132a: Fix possible linkage error
Make static the function ataes132a_atmel_crc implemented in
the private header to avoid possible linkage error if the file
is inlcluded ina different object unit.

Signed-off-by: Flavio Ceolin <flavio@hubble.com>
2026-07-12 20:01:09 -04:00
David J. Leach, Jr.
91f2980f6b drivers: crypto: ataes132a: fix integer overflows in CRC and commands
This commit addresses two integer handling issues in the ataes132a
crypto driver identified by coverity scans.

1. In ataes132a_send_command, added a centralized validation check
   to ensure the 'nparams' value, when combined with the 5-byte
   packet overhead, does not exceed the 8-bit 'count' limit or the
   physical 64-byte command buffer. This prevents a potential wrap-
   around that would cause the chip to receive an invalid length byte.

2. In the Atmel CRC calculation, added an explicit cast to uint16_t
   during the bit-shift operation. This prevents unintended integer
   promotion and satisfies static analysis regarding potential
   overflows during the 16-bit CRC generation.

Fixes #84683
Fixes #84690

Signed-off-by: David J. Leach, Jr. <tasmar@gmail.com>
2026-04-06 10:29:20 -05:00
Kumar Gala
3caaf8c935 drivers: crypto: ataes132a: Convert to devicetree
Move driver to be devicetree based and use struct i2c_dt_spec.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-14 10:37:26 +02:00
Gerard Marull-Paretas
fb60aab245 drivers: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all drivers to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 19:58:21 +02:00
Nazar Kazakov
9713f0d47c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-14 20:22:24 -04:00
Tomasz Bursztyka
e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka
98d9b01322 device: Apply driver_api/data attributes rename everywhere
Via coccinelle:

@r_device_driver_api_and_data_1@
struct device *D;
@@
(
D->
-	driver_api
+	api
|
D->
-	driver_data
+	data
)

@r_device_driver_api_and_data_2@
expression E;
@@
(
net_if_get_device(E)->
-	driver_api
+	api
|
net_if_get_device(E)->
-	driver_data
+	data
)

And grep/sed rules for macros:

git grep -rlz 'dev)->driver_data' |
	xargs -0 sed -i 's/dev)->driver_data/dev)->data/g'

git grep -rlz 'dev->driver_data' |
	xargs -0 sed -i 's/dev->driver_data/dev->data/g'

git grep -rlz 'device->driver_data' |
	xargs -0 sed -i 's/device->driver_data/device->data/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Kumar Gala
a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Anas Nashif
a2fd7d70ec cleanup: include/: move misc/util.h to sys/util.h
move misc/util.h to sys/util.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif
8f692c7d38 cleanup: include/: move i2c.h to drivers/i2c.h
move i2c.h to drivers/i2c.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Patrik Flykt
24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Patrik Flykt
8ff96b5a57 drivers: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Flavio Ceolin
67ca176754 headers: Fix headers across the project
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Kumar Gala
682455ec89 drivers: crypto_ataes132a: Fix typo in Kconfig symbol
In the code we had an if defined based on
CONFIG_ATAES132A_I2C_SPEED_STANDARD that should be
CONFIG_CRYPTO_ATAES132A_I2C_SPEED_STANDARD.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-05-23 17:57:06 -04:00
Kumar Gala
ccad5bf3e3 drivers: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I08f51e2bfd475f6245771c1bd2df7ffc744c48c4
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 10:06:48 -05:00
Juan Manuel Cruz Alcaraz
485da78449 ataes132a: Adds a driver to support ATAES132A device
Adds a driver for Atmel Crypto Authorization solution
ATAES132A crypto device.

The driver supports the following functionality.

- AES CCM encryption, decryption and authentication
- AES ECB block operation.

The driver requires an I2C device to access crypto device registers.

Jira: ZEP-1387

Change-Id: I60aa8f3b069b703d4f83d866d28391625bb9ac13
Signed-off-by: Juan Manuel Cruz Alcaraz <juan.m.cruz.alcaraz@intel.com>
2017-02-15 02:07:14 +00:00