SSLSession中的PacketBufferSize和ApplicationBufferSize

看了API描述还是不太清楚,所以翻源码来读,就清楚多了。


//定义的SSL 常量
interface Record {

static final byte ct_change_cipher_spec = 20;
static final byte ct_alert = 21;
static final byte ct_handshake = 22;
static final byte ct_application_data = 23;


static final int headerSize = 5; // SSLv3 record header
static final int maxExpansion = 1024; // for bad compression
static final int trailerSize = 20; // SHA1 hash size
static final int maxDataSize = 16384; // 2^14 bytes of data
static final int maxPadding = 256; // block cipher padding



static final int maxRecordSize = headerSize // header
+ maxDataSize // data
+ maxPadding // padding
+ trailerSize; // MAC



static final int maxLargeRecordSize = maxRecordSize // Max size with a conforming implemenation
+ maxDataSize; // extra 2^14 bytes for large data packets.



static final int maxAlertRecordSize = headerSize + 2 + maxPadding
+ trailerSize;


}



//大致意思,如果此标识为true,就破坏rfc标准,将上限提升到2的15次方
private boolean acceptLargeFragments = Debug.getBooleanProperty(
"jsse.SSLEngine.acceptLargeFragments", false);







public synchronized int getPacketBufferSize() {
return acceptLargeFragments ? Record.maxLargeRecordSize
: Record.maxRecordSize;
}



public synchronized int getApplicationBufferSize() {
return getPacketBufferSize() - Record.headerSize; // getPacketBufferSize() 减去header信息的长度
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值