efm32pg12_pac/crypto0/
wac.rs1#[doc = "Reader of register WAC"]
2pub type R = crate::R<u32, super::WAC>;
3#[doc = "Writer for register WAC"]
4pub type W = crate::W<u32, super::WAC>;
5#[doc = "Register WAC `reset()`'s with value 0"]
6impl crate::ResetValue for super::WAC {
7 type Type = u32;
8 #[inline(always)]
9 fn reset_value() -> Self::Type {
10 0
11 }
12}
13#[doc = "Modular Operation Modulus\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum MODULUS_A {
17 #[doc = "0: Generic modulus. p = 2^256"]
18 BIN256 = 0,
19 #[doc = "1: Generic modulus. p = 2^128"]
20 BIN128 = 1,
21 #[doc = "2: Modulus for B-233 and K-233 ECC curves. p(t) = t^233 + t^74 + 1"]
22 ECCBIN233P = 2,
23 #[doc = "3: Modulus for B-163 and K-163 ECC curves. p(t) = t^163 + t^7 + t^6 + t^3 + 1"]
24 ECCBIN163P = 3,
25 #[doc = "4: Modulus for GCM. P(t) = t^128 + t^7 + t^2 + t + 1"]
26 GCMBIN128 = 4,
27 #[doc = "5: Modulus for P-256 ECC curve. p = 2^256 - 2^224 + 2^192 + 2^96 - 1"]
28 ECCPRIME256P = 5,
29 #[doc = "6: Modulus for P-224 ECC curve. p = 2^224 - 2^96 - 1"]
30 ECCPRIME224P = 6,
31 #[doc = "7: Modulus for P-192 ECC curve. p = 2^192 - 2^64 - 1"]
32 ECCPRIME192P = 7,
33 #[doc = "8: P modulus for B-233 ECC curve"]
34 ECCBIN233N = 8,
35 #[doc = "9: P modulus for K-233 ECC curve"]
36 ECCBIN233KN = 9,
37 #[doc = "10: P modulus for B-163 ECC curve"]
38 ECCBIN163N = 10,
39 #[doc = "11: P modulus for K-163 ECC curve"]
40 ECCBIN163KN = 11,
41 #[doc = "12: P modulus for P-256 ECC curve"]
42 ECCPRIME256N = 12,
43 #[doc = "13: P modulus for P-224 ECC curve"]
44 ECCPRIME224N = 13,
45 #[doc = "14: P modulus for P-192 ECC curve"]
46 ECCPRIME192N = 14,
47}
48impl From<MODULUS_A> for u8 {
49 #[inline(always)]
50 fn from(variant: MODULUS_A) -> Self {
51 variant as _
52 }
53}
54#[doc = "Reader of field `MODULUS`"]
55pub type MODULUS_R = crate::R<u8, MODULUS_A>;
56impl MODULUS_R {
57 #[doc = r"Get enumerated values variant"]
58 #[inline(always)]
59 pub fn variant(&self) -> crate::Variant<u8, MODULUS_A> {
60 use crate::Variant::*;
61 match self.bits {
62 0 => Val(MODULUS_A::BIN256),
63 1 => Val(MODULUS_A::BIN128),
64 2 => Val(MODULUS_A::ECCBIN233P),
65 3 => Val(MODULUS_A::ECCBIN163P),
66 4 => Val(MODULUS_A::GCMBIN128),
67 5 => Val(MODULUS_A::ECCPRIME256P),
68 6 => Val(MODULUS_A::ECCPRIME224P),
69 7 => Val(MODULUS_A::ECCPRIME192P),
70 8 => Val(MODULUS_A::ECCBIN233N),
71 9 => Val(MODULUS_A::ECCBIN233KN),
72 10 => Val(MODULUS_A::ECCBIN163N),
73 11 => Val(MODULUS_A::ECCBIN163KN),
74 12 => Val(MODULUS_A::ECCPRIME256N),
75 13 => Val(MODULUS_A::ECCPRIME224N),
76 14 => Val(MODULUS_A::ECCPRIME192N),
77 i => Res(i),
78 }
79 }
80 #[doc = "Checks if the value of the field is `BIN256`"]
81 #[inline(always)]
82 pub fn is_bin256(&self) -> bool {
83 *self == MODULUS_A::BIN256
84 }
85 #[doc = "Checks if the value of the field is `BIN128`"]
86 #[inline(always)]
87 pub fn is_bin128(&self) -> bool {
88 *self == MODULUS_A::BIN128
89 }
90 #[doc = "Checks if the value of the field is `ECCBIN233P`"]
91 #[inline(always)]
92 pub fn is_eccbin233p(&self) -> bool {
93 *self == MODULUS_A::ECCBIN233P
94 }
95 #[doc = "Checks if the value of the field is `ECCBIN163P`"]
96 #[inline(always)]
97 pub fn is_eccbin163p(&self) -> bool {
98 *self == MODULUS_A::ECCBIN163P
99 }
100 #[doc = "Checks if the value of the field is `GCMBIN128`"]
101 #[inline(always)]
102 pub fn is_gcmbin128(&self) -> bool {
103 *self == MODULUS_A::GCMBIN128
104 }
105 #[doc = "Checks if the value of the field is `ECCPRIME256P`"]
106 #[inline(always)]
107 pub fn is_eccprime256p(&self) -> bool {
108 *self == MODULUS_A::ECCPRIME256P
109 }
110 #[doc = "Checks if the value of the field is `ECCPRIME224P`"]
111 #[inline(always)]
112 pub fn is_eccprime224p(&self) -> bool {
113 *self == MODULUS_A::ECCPRIME224P
114 }
115 #[doc = "Checks if the value of the field is `ECCPRIME192P`"]
116 #[inline(always)]
117 pub fn is_eccprime192p(&self) -> bool {
118 *self == MODULUS_A::ECCPRIME192P
119 }
120 #[doc = "Checks if the value of the field is `ECCBIN233N`"]
121 #[inline(always)]
122 pub fn is_eccbin233n(&self) -> bool {
123 *self == MODULUS_A::ECCBIN233N
124 }
125 #[doc = "Checks if the value of the field is `ECCBIN233KN`"]
126 #[inline(always)]
127 pub fn is_eccbin233kn(&self) -> bool {
128 *self == MODULUS_A::ECCBIN233KN
129 }
130 #[doc = "Checks if the value of the field is `ECCBIN163N`"]
131 #[inline(always)]
132 pub fn is_eccbin163n(&self) -> bool {
133 *self == MODULUS_A::ECCBIN163N
134 }
135 #[doc = "Checks if the value of the field is `ECCBIN163KN`"]
136 #[inline(always)]
137 pub fn is_eccbin163kn(&self) -> bool {
138 *self == MODULUS_A::ECCBIN163KN
139 }
140 #[doc = "Checks if the value of the field is `ECCPRIME256N`"]
141 #[inline(always)]
142 pub fn is_eccprime256n(&self) -> bool {
143 *self == MODULUS_A::ECCPRIME256N
144 }
145 #[doc = "Checks if the value of the field is `ECCPRIME224N`"]
146 #[inline(always)]
147 pub fn is_eccprime224n(&self) -> bool {
148 *self == MODULUS_A::ECCPRIME224N
149 }
150 #[doc = "Checks if the value of the field is `ECCPRIME192N`"]
151 #[inline(always)]
152 pub fn is_eccprime192n(&self) -> bool {
153 *self == MODULUS_A::ECCPRIME192N
154 }
155}
156#[doc = "Write proxy for field `MODULUS`"]
157pub struct MODULUS_W<'a> {
158 w: &'a mut W,
159}
160impl<'a> MODULUS_W<'a> {
161 #[doc = r"Writes `variant` to the field"]
162 #[inline(always)]
163 pub fn variant(self, variant: MODULUS_A) -> &'a mut W {
164 unsafe { self.bits(variant.into()) }
165 }
166 #[doc = "Generic modulus. p = 2^256"]
167 #[inline(always)]
168 pub fn bin256(self) -> &'a mut W {
169 self.variant(MODULUS_A::BIN256)
170 }
171 #[doc = "Generic modulus. p = 2^128"]
172 #[inline(always)]
173 pub fn bin128(self) -> &'a mut W {
174 self.variant(MODULUS_A::BIN128)
175 }
176 #[doc = "Modulus for B-233 and K-233 ECC curves. p(t) = t^233 + t^74 + 1"]
177 #[inline(always)]
178 pub fn eccbin233p(self) -> &'a mut W {
179 self.variant(MODULUS_A::ECCBIN233P)
180 }
181 #[doc = "Modulus for B-163 and K-163 ECC curves. p(t) = t^163 + t^7 + t^6 + t^3 + 1"]
182 #[inline(always)]
183 pub fn eccbin163p(self) -> &'a mut W {
184 self.variant(MODULUS_A::ECCBIN163P)
185 }
186 #[doc = "Modulus for GCM. P(t) = t^128 + t^7 + t^2 + t + 1"]
187 #[inline(always)]
188 pub fn gcmbin128(self) -> &'a mut W {
189 self.variant(MODULUS_A::GCMBIN128)
190 }
191 #[doc = "Modulus for P-256 ECC curve. p = 2^256 - 2^224 + 2^192 + 2^96 - 1"]
192 #[inline(always)]
193 pub fn eccprime256p(self) -> &'a mut W {
194 self.variant(MODULUS_A::ECCPRIME256P)
195 }
196 #[doc = "Modulus for P-224 ECC curve. p = 2^224 - 2^96 - 1"]
197 #[inline(always)]
198 pub fn eccprime224p(self) -> &'a mut W {
199 self.variant(MODULUS_A::ECCPRIME224P)
200 }
201 #[doc = "Modulus for P-192 ECC curve. p = 2^192 - 2^64 - 1"]
202 #[inline(always)]
203 pub fn eccprime192p(self) -> &'a mut W {
204 self.variant(MODULUS_A::ECCPRIME192P)
205 }
206 #[doc = "P modulus for B-233 ECC curve"]
207 #[inline(always)]
208 pub fn eccbin233n(self) -> &'a mut W {
209 self.variant(MODULUS_A::ECCBIN233N)
210 }
211 #[doc = "P modulus for K-233 ECC curve"]
212 #[inline(always)]
213 pub fn eccbin233kn(self) -> &'a mut W {
214 self.variant(MODULUS_A::ECCBIN233KN)
215 }
216 #[doc = "P modulus for B-163 ECC curve"]
217 #[inline(always)]
218 pub fn eccbin163n(self) -> &'a mut W {
219 self.variant(MODULUS_A::ECCBIN163N)
220 }
221 #[doc = "P modulus for K-163 ECC curve"]
222 #[inline(always)]
223 pub fn eccbin163kn(self) -> &'a mut W {
224 self.variant(MODULUS_A::ECCBIN163KN)
225 }
226 #[doc = "P modulus for P-256 ECC curve"]
227 #[inline(always)]
228 pub fn eccprime256n(self) -> &'a mut W {
229 self.variant(MODULUS_A::ECCPRIME256N)
230 }
231 #[doc = "P modulus for P-224 ECC curve"]
232 #[inline(always)]
233 pub fn eccprime224n(self) -> &'a mut W {
234 self.variant(MODULUS_A::ECCPRIME224N)
235 }
236 #[doc = "P modulus for P-192 ECC curve"]
237 #[inline(always)]
238 pub fn eccprime192n(self) -> &'a mut W {
239 self.variant(MODULUS_A::ECCPRIME192N)
240 }
241 #[doc = r"Writes raw bits to the field"]
242 #[inline(always)]
243 pub unsafe fn bits(self, value: u8) -> &'a mut W {
244 self.w.bits = (self.w.bits & !0x0f) | ((value as u32) & 0x0f);
245 self.w
246 }
247}
248#[doc = "Reader of field `MODOP`"]
249pub type MODOP_R = crate::R<bool, bool>;
250#[doc = "Write proxy for field `MODOP`"]
251pub struct MODOP_W<'a> {
252 w: &'a mut W,
253}
254impl<'a> MODOP_W<'a> {
255 #[doc = r"Sets the field bit"]
256 #[inline(always)]
257 pub fn set_bit(self) -> &'a mut W {
258 self.bit(true)
259 }
260 #[doc = r"Clears the field bit"]
261 #[inline(always)]
262 pub fn clear_bit(self) -> &'a mut W {
263 self.bit(false)
264 }
265 #[doc = r"Writes raw bits to the field"]
266 #[inline(always)]
267 pub fn bit(self, value: bool) -> &'a mut W {
268 self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4);
269 self.w
270 }
271}
272#[doc = "Multiply Width\n\nValue on reset: 0"]
273#[derive(Clone, Copy, Debug, PartialEq)]
274#[repr(u8)]
275pub enum MULWIDTH_A {
276 #[doc = "0: Multiply 256 bits"]
277 MUL256 = 0,
278 #[doc = "1: Multiply 128 bits"]
279 MUL128 = 1,
280 #[doc = "2: Same number of bits as specified by MODULUS"]
281 MULMOD = 2,
282}
283impl From<MULWIDTH_A> for u8 {
284 #[inline(always)]
285 fn from(variant: MULWIDTH_A) -> Self {
286 variant as _
287 }
288}
289#[doc = "Reader of field `MULWIDTH`"]
290pub type MULWIDTH_R = crate::R<u8, MULWIDTH_A>;
291impl MULWIDTH_R {
292 #[doc = r"Get enumerated values variant"]
293 #[inline(always)]
294 pub fn variant(&self) -> crate::Variant<u8, MULWIDTH_A> {
295 use crate::Variant::*;
296 match self.bits {
297 0 => Val(MULWIDTH_A::MUL256),
298 1 => Val(MULWIDTH_A::MUL128),
299 2 => Val(MULWIDTH_A::MULMOD),
300 i => Res(i),
301 }
302 }
303 #[doc = "Checks if the value of the field is `MUL256`"]
304 #[inline(always)]
305 pub fn is_mul256(&self) -> bool {
306 *self == MULWIDTH_A::MUL256
307 }
308 #[doc = "Checks if the value of the field is `MUL128`"]
309 #[inline(always)]
310 pub fn is_mul128(&self) -> bool {
311 *self == MULWIDTH_A::MUL128
312 }
313 #[doc = "Checks if the value of the field is `MULMOD`"]
314 #[inline(always)]
315 pub fn is_mulmod(&self) -> bool {
316 *self == MULWIDTH_A::MULMOD
317 }
318}
319#[doc = "Write proxy for field `MULWIDTH`"]
320pub struct MULWIDTH_W<'a> {
321 w: &'a mut W,
322}
323impl<'a> MULWIDTH_W<'a> {
324 #[doc = r"Writes `variant` to the field"]
325 #[inline(always)]
326 pub fn variant(self, variant: MULWIDTH_A) -> &'a mut W {
327 unsafe { self.bits(variant.into()) }
328 }
329 #[doc = "Multiply 256 bits"]
330 #[inline(always)]
331 pub fn mul256(self) -> &'a mut W {
332 self.variant(MULWIDTH_A::MUL256)
333 }
334 #[doc = "Multiply 128 bits"]
335 #[inline(always)]
336 pub fn mul128(self) -> &'a mut W {
337 self.variant(MULWIDTH_A::MUL128)
338 }
339 #[doc = "Same number of bits as specified by MODULUS"]
340 #[inline(always)]
341 pub fn mulmod(self) -> &'a mut W {
342 self.variant(MULWIDTH_A::MULMOD)
343 }
344 #[doc = r"Writes raw bits to the field"]
345 #[inline(always)]
346 pub unsafe fn bits(self, value: u8) -> &'a mut W {
347 self.w.bits = (self.w.bits & !(0x03 << 8)) | (((value as u32) & 0x03) << 8);
348 self.w
349 }
350}
351#[doc = "Result Width\n\nValue on reset: 0"]
352#[derive(Clone, Copy, Debug, PartialEq)]
353#[repr(u8)]
354pub enum RESULTWIDTH_A {
355 #[doc = "0: Results have 256 bits"]
356 _256BIT = 0,
357 #[doc = "1: Results have 128 bits"]
358 _128BIT = 1,
359 #[doc = "2: Results have 260 bits. Upper bits of result can be read through DDATA0MSBS in CRYPTO_STATUS"]
360 _260BIT = 2,
361}
362impl From<RESULTWIDTH_A> for u8 {
363 #[inline(always)]
364 fn from(variant: RESULTWIDTH_A) -> Self {
365 variant as _
366 }
367}
368#[doc = "Reader of field `RESULTWIDTH`"]
369pub type RESULTWIDTH_R = crate::R<u8, RESULTWIDTH_A>;
370impl RESULTWIDTH_R {
371 #[doc = r"Get enumerated values variant"]
372 #[inline(always)]
373 pub fn variant(&self) -> crate::Variant<u8, RESULTWIDTH_A> {
374 use crate::Variant::*;
375 match self.bits {
376 0 => Val(RESULTWIDTH_A::_256BIT),
377 1 => Val(RESULTWIDTH_A::_128BIT),
378 2 => Val(RESULTWIDTH_A::_260BIT),
379 i => Res(i),
380 }
381 }
382 #[doc = "Checks if the value of the field is `_256BIT`"]
383 #[inline(always)]
384 pub fn is_256bit(&self) -> bool {
385 *self == RESULTWIDTH_A::_256BIT
386 }
387 #[doc = "Checks if the value of the field is `_128BIT`"]
388 #[inline(always)]
389 pub fn is_128bit(&self) -> bool {
390 *self == RESULTWIDTH_A::_128BIT
391 }
392 #[doc = "Checks if the value of the field is `_260BIT`"]
393 #[inline(always)]
394 pub fn is_260bit(&self) -> bool {
395 *self == RESULTWIDTH_A::_260BIT
396 }
397}
398#[doc = "Write proxy for field `RESULTWIDTH`"]
399pub struct RESULTWIDTH_W<'a> {
400 w: &'a mut W,
401}
402impl<'a> RESULTWIDTH_W<'a> {
403 #[doc = r"Writes `variant` to the field"]
404 #[inline(always)]
405 pub fn variant(self, variant: RESULTWIDTH_A) -> &'a mut W {
406 unsafe { self.bits(variant.into()) }
407 }
408 #[doc = "Results have 256 bits"]
409 #[inline(always)]
410 pub fn _256bit(self) -> &'a mut W {
411 self.variant(RESULTWIDTH_A::_256BIT)
412 }
413 #[doc = "Results have 128 bits"]
414 #[inline(always)]
415 pub fn _128bit(self) -> &'a mut W {
416 self.variant(RESULTWIDTH_A::_128BIT)
417 }
418 #[doc = "Results have 260 bits. Upper bits of result can be read through DDATA0MSBS in CRYPTO_STATUS"]
419 #[inline(always)]
420 pub fn _260bit(self) -> &'a mut W {
421 self.variant(RESULTWIDTH_A::_260BIT)
422 }
423 #[doc = r"Writes raw bits to the field"]
424 #[inline(always)]
425 pub unsafe fn bits(self, value: u8) -> &'a mut W {
426 self.w.bits = (self.w.bits & !(0x03 << 10)) | (((value as u32) & 0x03) << 10);
427 self.w
428 }
429}
430impl R {
431 #[doc = "Bits 0:3 - Modular Operation Modulus"]
432 #[inline(always)]
433 pub fn modulus(&self) -> MODULUS_R {
434 MODULUS_R::new((self.bits & 0x0f) as u8)
435 }
436 #[doc = "Bit 4 - Modular Operation Field Type"]
437 #[inline(always)]
438 pub fn modop(&self) -> MODOP_R {
439 MODOP_R::new(((self.bits >> 4) & 0x01) != 0)
440 }
441 #[doc = "Bits 8:9 - Multiply Width"]
442 #[inline(always)]
443 pub fn mulwidth(&self) -> MULWIDTH_R {
444 MULWIDTH_R::new(((self.bits >> 8) & 0x03) as u8)
445 }
446 #[doc = "Bits 10:11 - Result Width"]
447 #[inline(always)]
448 pub fn resultwidth(&self) -> RESULTWIDTH_R {
449 RESULTWIDTH_R::new(((self.bits >> 10) & 0x03) as u8)
450 }
451}
452impl W {
453 #[doc = "Bits 0:3 - Modular Operation Modulus"]
454 #[inline(always)]
455 pub fn modulus(&mut self) -> MODULUS_W {
456 MODULUS_W { w: self }
457 }
458 #[doc = "Bit 4 - Modular Operation Field Type"]
459 #[inline(always)]
460 pub fn modop(&mut self) -> MODOP_W {
461 MODOP_W { w: self }
462 }
463 #[doc = "Bits 8:9 - Multiply Width"]
464 #[inline(always)]
465 pub fn mulwidth(&mut self) -> MULWIDTH_W {
466 MULWIDTH_W { w: self }
467 }
468 #[doc = "Bits 10:11 - Result Width"]
469 #[inline(always)]
470 pub fn resultwidth(&mut self) -> RESULTWIDTH_W {
471 RESULTWIDTH_W { w: self }
472 }
473}