@@ -8,7 +8,7 @@ namespace Org.BouncyCastle.Tls.Crypto.Impl
8
8
{
9
9
/// <summary>A generic TLS 1.0-1.2 block cipher. This can be used for AES or 3DES for example.</summary>
10
10
public class TlsBlockCipher
11
- : AbstractTlsCipher
11
+ : TlsCipher , TlsCipherExt
12
12
{
13
13
protected readonly TlsCryptoParameters m_cryptoParams ;
14
14
protected readonly byte [ ] m_randomData ;
@@ -155,7 +155,7 @@ public TlsBlockCipher(TlsCryptoParameters cryptoParams, TlsBlockCipherImpl encry
155
155
}
156
156
}
157
157
158
- public override int GetCiphertextDecodeLimit ( int plaintextLimit )
158
+ public virtual int GetCiphertextDecodeLimit ( int plaintextLimit )
159
159
{
160
160
int blockSize = m_decryptCipher . GetBlockSize ( ) ;
161
161
int macSize = m_readMac . Size ;
@@ -165,7 +165,7 @@ public override int GetCiphertextDecodeLimit(int plaintextLimit)
165
165
return GetCiphertextLength ( blockSize , macSize , maxPadding , innerPlaintextLimit ) ;
166
166
}
167
167
168
- public override int GetCiphertextEncodeLimit ( int plaintextLength , int plaintextLimit )
168
+ public virtual int GetCiphertextEncodeLimit ( int plaintextLength , int plaintextLimit )
169
169
{
170
170
plaintextLimit = System . Math . Min ( plaintextLength , plaintextLimit ) ;
171
171
@@ -177,7 +177,13 @@ public override int GetCiphertextEncodeLimit(int plaintextLength, int plaintextL
177
177
return GetCiphertextLength ( blockSize , macSize , maxPadding , innerPlaintextLimit ) ;
178
178
}
179
179
180
- public override int GetPlaintextDecodeLimit ( int ciphertextLimit )
180
+ // TODO[api] Remove
181
+ public virtual int GetPlaintextLimit ( int ciphertextLimit )
182
+ {
183
+ return GetPlaintextEncodeLimit ( ciphertextLimit ) ;
184
+ }
185
+
186
+ public virtual int GetPlaintextDecodeLimit ( int ciphertextLimit )
181
187
{
182
188
int blockSize = m_decryptCipher . GetBlockSize ( ) ;
183
189
int macSize = m_readMac . Size ;
@@ -187,7 +193,7 @@ public override int GetPlaintextDecodeLimit(int ciphertextLimit)
187
193
return innerPlaintextLimit - ( m_decryptUseInnerPlaintext ? 1 : 0 ) ;
188
194
}
189
195
190
- public override int GetPlaintextEncodeLimit ( int ciphertextLimit )
196
+ public virtual int GetPlaintextEncodeLimit ( int ciphertextLimit )
191
197
{
192
198
int blockSize = m_encryptCipher . GetBlockSize ( ) ;
193
199
int macSize = m_writeMac . Size ;
@@ -197,7 +203,7 @@ public override int GetPlaintextEncodeLimit(int ciphertextLimit)
197
203
return innerPlaintextLimit - ( m_encryptUseInnerPlaintext ? 1 : 0 ) ;
198
204
}
199
205
200
- public override TlsEncodeResult EncodePlaintext ( long seqNo , short contentType , ProtocolVersion recordVersion ,
206
+ public virtual TlsEncodeResult EncodePlaintext ( long seqNo , short contentType , ProtocolVersion recordVersion ,
201
207
int headerAllocation , byte [ ] plaintext , int offset , int len )
202
208
{
203
209
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
@@ -285,7 +291,7 @@ public override TlsEncodeResult EncodePlaintext(long seqNo, short contentType, P
285
291
}
286
292
287
293
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
288
- public override TlsEncodeResult EncodePlaintext ( long seqNo , short contentType , ProtocolVersion recordVersion ,
294
+ public virtual TlsEncodeResult EncodePlaintext ( long seqNo , short contentType , ProtocolVersion recordVersion ,
289
295
int headerAllocation , ReadOnlySpan < byte > plaintext )
290
296
{
291
297
int blockSize = m_encryptCipher . GetBlockSize ( ) ;
@@ -369,7 +375,7 @@ public override TlsEncodeResult EncodePlaintext(long seqNo, short contentType, P
369
375
}
370
376
#endif
371
377
372
- public override TlsDecodeResult DecodeCiphertext ( long seqNo , short recordType , ProtocolVersion recordVersion ,
378
+ public virtual TlsDecodeResult DecodeCiphertext ( long seqNo , short recordType , ProtocolVersion recordVersion ,
373
379
byte [ ] ciphertext , int offset , int len )
374
380
{
375
381
int blockSize = m_decryptCipher . GetBlockSize ( ) ;
@@ -475,7 +481,17 @@ public override TlsDecodeResult DecodeCiphertext(long seqNo, short recordType, P
475
481
return new TlsDecodeResult ( ciphertext , offset , plaintextLength , contentType ) ;
476
482
}
477
483
478
- public override bool UsesOpaqueRecordType
484
+ public virtual void RekeyDecoder ( )
485
+ {
486
+ throw new TlsFatalAlert ( AlertDescription . internal_error ) ;
487
+ }
488
+
489
+ public virtual void RekeyEncoder ( )
490
+ {
491
+ throw new TlsFatalAlert ( AlertDescription . internal_error ) ;
492
+ }
493
+
494
+ public virtual bool UsesOpaqueRecordType
479
495
{
480
496
get { return false ; }
481
497
}
0 commit comments