vitaminc-protected 0.2.0-pre.1

Protected type wrappers for handling sensitive data. Part of the VitaminC cryptographic suite.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::Protected;
use std::ops::{Index, IndexMut};

/// Allows the use a of a Paranoid usize to index an array.
impl<const N: usize, T> Index<Protected<usize>> for [T; N] {
    type Output = T;

    fn index(&self, index: Protected<usize>) -> &Self::Output {
        &self[index.0]
    }
}

impl<const N: usize, T> IndexMut<Protected<usize>> for [T; N] {
    fn index_mut(&mut self, index: Protected<usize>) -> &mut Self::Output {
        &mut self[index.0]
    }
}