@@ -41,7 +41,7 @@ public Aes128Gcm(ByteSpan key)
4141
4242 // Allocate scratch space
4343 ByteSpan scratchSpace = new byte [ 96 ] ;
44- hashSubkey_ = scratchSpace . Slice ( 0 , 16 ) ;
44+ hashSubkey_ = scratchSpace [ .. 16 ] ;
4545 blockJ_ = scratchSpace . Slice ( 16 , 16 ) ;
4646 blockS_ = scratchSpace . Slice ( 32 , 16 ) ;
4747 blockZ_ = scratchSpace . Slice ( 48 , 16 ) ;
@@ -89,7 +89,7 @@ public void Seal(ByteSpan output, ByteSpan nonce, ByteSpan plaintext, ByteSpan a
8989
9090 // Generate and append the authentication tag
9191 var tagOffset = plaintext . Length ;
92- GenerateAuthenticationTag ( output . Slice ( tagOffset ) , output . Slice ( 0 , tagOffset ) , associatedData ) ;
92+ GenerateAuthenticationTag ( output [ tagOffset .. ] , output [ .. tagOffset ] , associatedData ) ;
9393 }
9494
9595 /// <summary>
@@ -126,8 +126,8 @@ public bool Open(ByteSpan output, ByteSpan nonce, ByteSpan ciphertext, ByteSpan
126126
127127 // Split ciphertext into actual ciphertext and authentication
128128 // tag components.
129- var authenticationTag = ciphertext . Slice ( ciphertext . Length - TagSize ) ;
130- ciphertext = ciphertext . Slice ( 0 , ciphertext . Length - TagSize ) ;
129+ var authenticationTag = ciphertext [ ^ TagSize .. ] ;
130+ ciphertext = ciphertext [ .. ^ TagSize ] ;
131131
132132 // Create the initial counter block
133133 nonce . CopyTo ( blockJ_ ) ;
@@ -158,7 +158,7 @@ private void GenerateAuthenticationTag(ByteSpan output, ByteSpan ciphertext, Byt
158158 if ( fullBlocks * 16 < associatedData . Length )
159159 {
160160 SetSpanToZeros ( blockScratch_ ) ;
161- associatedData . Slice ( fullBlocks * 16 ) . CopyTo ( blockScratch_ ) ;
161+ associatedData [ ( fullBlocks * 16 ) .. ] . CopyTo ( blockScratch_ ) ;
162162 GHASH ( blockS_ , blockScratch_ , 1 ) ;
163163 }
164164
@@ -168,7 +168,7 @@ private void GenerateAuthenticationTag(ByteSpan output, ByteSpan ciphertext, Byt
168168 if ( fullBlocks * 16 < ciphertext . Length )
169169 {
170170 SetSpanToZeros ( blockScratch_ ) ;
171- ciphertext . Slice ( fullBlocks * 16 ) . CopyTo ( blockScratch_ ) ;
171+ ciphertext [ ( fullBlocks * 16 ) .. ] . CopyTo ( blockScratch_ ) ;
172172 GHASH ( blockS_ , blockScratch_ , 1 ) ;
173173 }
174174
@@ -205,7 +205,7 @@ private void GCTR(ByteSpan output, ByteSpan counterBlock, uint counter, ByteSpan
205205 ++ counter ;
206206
207207 // CIPH[k](CB[i])
208- encryptor_ . EncryptBlock ( counterBlock . Slice ( 0 , 16 ) , blockScratch_ ) ;
208+ encryptor_ . EncryptBlock ( counterBlock [ .. 16 ] , blockScratch_ ) ;
209209
210210 // Y[i] = X[i] xor CIPH[k](CB[i])
211211 for ( var jj = 0 ; jj != 16 && writeIndex < data . Length ; ++ jj , ++ writeIndex )
0 commit comments