MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / UnPad

Method UnPad

extra/yassl/taocrypt/src/rsa.cpp:105–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105word32 RSA_BlockType2::UnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
106 byte *output) const
107{
108 bool invalid = false;
109 unsigned int maxOutputLen = SaturatingSubtract(pkcsBlockLen / 8, 10U);
110
111 // convert from bit length to byte length
112 if (pkcsBlockLen % 8 != 0)
113 {
114 invalid = (pkcsBlock[0] != 0) || invalid;
115 pkcsBlock++;
116 }
117 pkcsBlockLen /= 8;
118
119 // Require block type 2.
120 invalid = (pkcsBlock[0] != 2) || invalid;
121
122 // skip past the padding until we find the separator
123 unsigned i=1;
124 while (i<pkcsBlockLen && pkcsBlock[i++]) { // null body
125 }
126 if (!(i==pkcsBlockLen || pkcsBlock[i-1]==0))
127 return 0;
128
129 unsigned int outputLen = pkcsBlockLen - i;
130 invalid = (outputLen > maxOutputLen) || invalid;
131
132 if (invalid)
133 return 0;
134
135 memcpy (output, pkcsBlock+i, outputLen);
136 return outputLen;
137}
138
139
140void RSA_BlockType1::Pad(const byte* input, word32 inputLen, byte* pkcsBlock,

Callers 2

SSL_DecryptFunction · 0.80
DecryptMethod · 0.80

Calls 1

SaturatingSubtractFunction · 0.85

Tested by

no test coverage detected