Repo of no-std crates for my personal embedded projects

Sachy's crypto scheme lmao #13

merged opened by sachy.dev targeting main from sachy-crypto
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:usjm3ynnir6y4inkcdovrfei/sh.tangled.repo.pull/3mhklndgukc22
+33 -99
Interdiff #5 #6
+21 -95
Cargo.lock
··· 1843 1843 1844 1844 [[package]] 1845 1845 name = "terminal_size" 1846 - version = "0.4.3" 1846 + version = "0.4.4" 1847 1847 source = "registry+https://github.com/rust-lang/crates.io-index" 1848 - checksum = "60b8cb979cb11c32ce1603f8137b22262a9d131aaa5c37b5678025f22b8becd0" 1848 + checksum = "230a1b821ccbd75b185820a1f1ff7b14d21da1e442e22c0863ea5f08771a8874" 1849 1849 dependencies = [ 1850 1850 "rustix 1.1.4", 1851 - "windows-sys 0.60.2", 1851 + "windows-sys 0.61.2", 1852 1852 ] 1853 1853 1854 1854 [[package]] ··· 1903 1903 1904 1904 [[package]] 1905 1905 name = "toml_datetime" 1906 - version = "1.0.1+spec-1.1.0" 1906 + version = "1.1.0+spec-1.1.0" 1907 1907 source = "registry+https://github.com/rust-lang/crates.io-index" 1908 - checksum = "9b320e741db58cac564e26c607d3cc1fdc4a88fd36c879568c07856ed83ff3e9" 1908 + checksum = "97251a7c317e03ad83774a8752a7e81fb6067740609f75ea2b585b569a59198f" 1909 1909 dependencies = [ 1910 1910 "serde_core", 1911 1911 ] 1912 1912 1913 1913 [[package]] 1914 1914 name = "toml_edit" 1915 - version = "0.25.5+spec-1.1.0" 1915 + version = "0.25.8+spec-1.1.0" 1916 1916 source = "registry+https://github.com/rust-lang/crates.io-index" 1917 - checksum = "8ca1a40644a28bce036923f6a431df0b34236949d111cc07cb6dca830c9ef2e1" 1917 + checksum = "16bff38f1d86c47f9ff0647e6838d7bb362522bdf44006c7068c2b1e606f1f3c" 1918 1918 dependencies = [ 1919 1919 "indexmap", 1920 1920 "toml_datetime", ··· 1925 1925 1926 1926 [[package]] 1927 1927 name = "toml_parser" 1928 - version = "1.0.10+spec-1.1.0" 1928 + version = "1.1.0+spec-1.1.0" 1929 1929 source = "registry+https://github.com/rust-lang/crates.io-index" 1930 - checksum = "7df25b4befd31c4816df190124375d5a20c6b6921e2cad937316de3fccd63420" 1930 + checksum = "2334f11ee363607eb04df9b8fc8a13ca1715a72ba8662a26ac285c98aabb4011" 1931 1931 dependencies = [ 1932 1932 "winnow 1.0.0", 1933 1933 ] 1934 1934 1935 1935 [[package]] 1936 1936 name = "toml_writer" 1937 - version = "1.0.7+spec-1.1.0" 1937 + version = "1.1.0+spec-1.1.0" 1938 1938 source = "registry+https://github.com/rust-lang/crates.io-index" 1939 - checksum = "f17aaa1c6e3dc22b1da4b6bba97d066e354c7945cac2f7852d4e4e7ca7a6b56d" 1939 + checksum = "d282ade6016312faf3e41e57ebbba0c073e4056dab1232ab1cb624199648f8ed" 1940 1940 1941 1941 [[package]] 1942 1942 name = "typenum" ··· 2087 2087 source = "registry+https://github.com/rust-lang/crates.io-index" 2088 2088 checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 2089 2089 dependencies = [ 2090 - "windows-targets 0.52.6", 2090 + "windows-targets", 2091 2091 ] 2092 2092 2093 2093 [[package]] ··· 2096 2096 source = "registry+https://github.com/rust-lang/crates.io-index" 2097 2097 checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" 2098 2098 dependencies = [ 2099 - "windows-targets 0.52.6", 2100 - ] 2101 - 2102 - [[package]] 2103 - name = "windows-sys" 2104 - version = "0.60.2" 2105 - source = "registry+https://github.com/rust-lang/crates.io-index" 2106 - checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" 2107 - dependencies = [ 2108 - "windows-targets 0.53.5", 2099 + "windows-targets", 2109 2100 ] 2110 2101 2111 2102 [[package]] ··· 2123 2114 source = "registry+https://github.com/rust-lang/crates.io-index" 2124 2115 checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 2125 2116 dependencies = [ 2126 - "windows_aarch64_gnullvm 0.52.6", 2127 - "windows_aarch64_msvc 0.52.6", 2128 - "windows_i686_gnu 0.52.6", 2129 - "windows_i686_gnullvm 0.52.6", 2130 - "windows_i686_msvc 0.52.6", 2131 - "windows_x86_64_gnu 0.52.6", 2132 - "windows_x86_64_gnullvm 0.52.6", 2133 - "windows_x86_64_msvc 0.52.6", 2134 - ] 2135 - 2136 - [[package]] 2137 - name = "windows-targets" 2138 - version = "0.53.5" 2139 - source = "registry+https://github.com/rust-lang/crates.io-index" 2140 - checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" 2141 - dependencies = [ 2142 - "windows-link", 2143 - "windows_aarch64_gnullvm 0.53.1", 2144 - "windows_aarch64_msvc 0.53.1", 2145 - "windows_i686_gnu 0.53.1", 2146 - "windows_i686_gnullvm 0.53.1", 2147 - "windows_i686_msvc 0.53.1", 2148 - "windows_x86_64_gnu 0.53.1", 2149 - "windows_x86_64_gnullvm 0.53.1", 2150 - "windows_x86_64_msvc 0.53.1", 2117 + "windows_aarch64_gnullvm", 2118 + "windows_aarch64_msvc", 2119 + "windows_i686_gnu", 2120 + "windows_i686_gnullvm", 2121 + "windows_i686_msvc", 2122 + "windows_x86_64_gnu", 2123 + "windows_x86_64_gnullvm", 2124 + "windows_x86_64_msvc", 2151 2125 ] 2152 2126 2153 2127 [[package]] ··· 2157 2131 checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 2158 2132 2159 2133 [[package]] 2160 - name = "windows_aarch64_gnullvm" 2161 - version = "0.53.1" 2162 - source = "registry+https://github.com/rust-lang/crates.io-index" 2163 - checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" 2164 - 2165 - [[package]] 2166 2134 name = "windows_aarch64_msvc" 2167 2135 version = "0.52.6" 2168 2136 source = "registry+https://github.com/rust-lang/crates.io-index" 2169 2137 checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 2170 2138 2171 2139 [[package]] 2172 - name = "windows_aarch64_msvc" 2173 - version = "0.53.1" 2174 - source = "registry+https://github.com/rust-lang/crates.io-index" 2175 - checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" 2176 - 2177 - [[package]] 2178 2140 name = "windows_i686_gnu" 2179 2141 version = "0.52.6" 2180 2142 source = "registry+https://github.com/rust-lang/crates.io-index" 2181 2143 checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 2182 2144 2183 2145 [[package]] 2184 - name = "windows_i686_gnu" 2185 - version = "0.53.1" 2186 - source = "registry+https://github.com/rust-lang/crates.io-index" 2187 - checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" 2188 - 2189 - [[package]] 2190 2146 name = "windows_i686_gnullvm" 2191 2147 version = "0.52.6" 2192 2148 source = "registry+https://github.com/rust-lang/crates.io-index" 2193 2149 checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 2194 2150 2195 2151 [[package]] 2196 - name = "windows_i686_gnullvm" 2197 - version = "0.53.1" 2198 - source = "registry+https://github.com/rust-lang/crates.io-index" 2199 - checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" 2200 - 2201 - [[package]] 2202 2152 name = "windows_i686_msvc" 2203 2153 version = "0.52.6" 2204 2154 source = "registry+https://github.com/rust-lang/crates.io-index" 2205 2155 checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 2206 2156 2207 2157 [[package]] 2208 - name = "windows_i686_msvc" 2209 - version = "0.53.1" 2210 - source = "registry+https://github.com/rust-lang/crates.io-index" 2211 - checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" 2212 - 2213 - [[package]] 2214 2158 name = "windows_x86_64_gnu" 2215 2159 version = "0.52.6" 2216 2160 source = "registry+https://github.com/rust-lang/crates.io-index" 2217 2161 checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 2218 2162 2219 2163 [[package]] 2220 - name = "windows_x86_64_gnu" 2221 - version = "0.53.1" 2222 - source = "registry+https://github.com/rust-lang/crates.io-index" 2223 - checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" 2224 - 2225 - [[package]] 2226 2164 name = "windows_x86_64_gnullvm" 2227 2165 version = "0.52.6" 2228 2166 source = "registry+https://github.com/rust-lang/crates.io-index" 2229 2167 checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 2230 2168 2231 2169 [[package]] 2232 - name = "windows_x86_64_gnullvm" 2233 - version = "0.53.1" 2234 - source = "registry+https://github.com/rust-lang/crates.io-index" 2235 - checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" 2236 - 2237 - [[package]] 2238 2170 name = "windows_x86_64_msvc" 2239 2171 version = "0.52.6" 2240 2172 2241 2173 checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 2242 2174 2243 2175 [[package]] 2244 - name = "windows_x86_64_msvc" 2245 - version = "0.53.1" 2246 - source = "registry+https://github.com/rust-lang/crates.io-index" 2247 - checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" 2248 - 2249 - [[package]] 2250 2176 name = "winnow" 2251 2177 version = "0.7.15" 2252 2178 source = "registry+https://github.com/rust-lang/crates.io-index"
Cargo.toml

This file has not been changed.

sachy-crypto/Cargo.toml

This file has not been changed.

+12 -4
sachy-crypto/src/lib.rs
··· 131 131 fn encrypt_in_place( 132 132 &self, 133 133 nonce: &aead::Nonce<A>, 134 + associated_data: &[u8], 134 135 buffer: &mut dyn Buffer, 135 136 ) -> Result<(), ProtoError>; 136 137 ··· 138 139 fn decrypt_in_place( 139 140 &self, 140 141 nonce: &aead::Nonce<A>, 142 + associated_data: &[u8], 141 143 buffer: &mut dyn Buffer, 142 144 ) -> Result<(), ProtoError>; 143 145 } ··· 169 171 pub fn encrypt(&mut self, msg: &mut alloc::vec::Vec<u8>) -> Result<(), ProtoError> { 170 172 let epstein = self.aead_nonce(self.counter); 171 173 172 - self.transport.encrypt_in_place(&epstein, msg)?; 174 + self.transport 175 + .encrypt_in_place(&epstein, &self.counter.to_le_bytes(), msg)?; 173 176 174 177 msg.extend(epstein); 175 178 ··· 195 198 // Extract the nonce from the payload as this does not need to be decrypted 196 199 let epstein = Array::try_from_iter(msg.drain(index..)).map_err(|_| ProtoError)?; 197 200 198 - self.transport.decrypt_in_place(&epstein, msg)?; 201 + self.transport 202 + .decrypt_in_place(&epstein, &self.counter.to_le_bytes(), msg)?; 199 203 200 204 self.counter += TransportState::COUNTER_INCR; 201 205 ··· 219 223 fn encrypt_in_place( 220 224 &self, 221 225 epstein: &aead::Nonce<XChaCha20Poly1305>, 226 + associated_data: &[u8], 222 227 buffer: &mut dyn Buffer, 223 228 ) -> Result<(), ProtoError> { 224 - self.aead.encrypt_in_place(epstein, epstein, buffer)?; 229 + self.aead 230 + .encrypt_in_place(epstein, associated_data, buffer)?; 225 231 Ok(()) 226 232 } 227 233 228 234 fn decrypt_in_place( 229 235 &self, 230 236 epstein: &aead::Nonce<XChaCha20Poly1305>, 237 + associated_data: &[u8], 231 238 buffer: &mut dyn Buffer, 232 239 ) -> Result<(), ProtoError> { 233 - self.aead.decrypt_in_place(epstein, epstein, buffer)?; 240 + self.aead 241 + .decrypt_in_place(epstein, associated_data, buffer)?; 234 242 Ok(()) 235 243 } 236 244 }

History

18 rounds 0 comments
sign up or login to add to the discussion
1 commit
expand
Sachy's crypto scheme lmao
2/2 success
expand
expand 0 comments
pull request successfully merged
1 commit
expand
Sachy's crypto scheme lmao
1/2 failed, 1/2 success
expand
expand 0 comments
1 commit
expand
Sachy's crypto scheme lmao
2/2 success
expand
expand 0 comments
1 commit
expand
Sachy's crypto scheme lmao
2/2 success
expand
expand 0 comments
1 commit
expand
Sachy's crypto scheme lmao
2/2 success
expand
expand 0 comments
1 commit
expand
Sachy's crypto scheme lmao
1/2 failed, 1/2 success
expand
expand 0 comments
1 commit
expand
Sachy's crypto scheme lmao
2/2 success
expand
expand 0 comments
1 commit
expand
Sachy's crypto scheme lmao
2/2 success
expand
expand 0 comments
1 commit
expand
Sachy's crypto scheme lmao
2/2 success
expand
expand 0 comments
1 commit
expand
Sachy's crypto scheme lmao
2/2 success
expand
expand 0 comments
1 commit
expand
Sachy's crypto scheme lmao
2/2 success
expand
expand 0 comments
sachy.dev submitted #6
1 commit
expand
Sachy's crypto scheme lmao
2/2 failed
expand
expand 0 comments
1 commit
expand
Sachy's crypto scheme lmao
2/2 success
expand
expand 0 comments
1 commit
expand
Sachy's crypto scheme lmao
2/2 success
expand
expand 0 comments
1 commit
expand
Sachy's crypto scheme lmao
2/2 success
expand
expand 0 comments
1 commit
expand
Sachy's crypto scheme lmao
2/2 success
expand
expand 0 comments
1 commit
expand
Sachy's crypto scheme lmao
2/2 success
expand
expand 0 comments
sachy.dev submitted #0
1 commit
expand
Sachy's crypto scheme lmao
2/2 success
expand
expand 0 comments