signChunk - signs a chunk read from s.baseReader of chunkLen size.
(chunkLen int, addCrLf bool)
| 218 | |
| 219 | // signChunk - signs a chunk read from s.baseReader of chunkLen size. |
| 220 | func (s *StreamingReader) signChunk(chunkLen int, addCrLf bool) { |
| 221 | // Compute chunk signature for next header |
| 222 | s.sh256.Reset() |
| 223 | s.sh256.Write(s.chunkBuf[:chunkLen]) |
| 224 | chunckChecksum := hex.EncodeToString(s.sh256.Sum(nil)) |
| 225 | |
| 226 | serviceType := s.serviceType |
| 227 | if serviceType == "" { |
| 228 | serviceType = ServiceTypeS3 |
| 229 | } |
| 230 | signature := buildChunkSignature(chunckChecksum, s.reqTime, |
| 231 | s.region, s.prevSignature, s.secretAccessKey, serviceType) |
| 232 | |
| 233 | // For next chunk signature computation |
| 234 | s.prevSignature = signature |
| 235 | |
| 236 | // Write chunk header into streaming buffer |
| 237 | chunkHdr := buildChunkHeader(int64(chunkLen), signature) |
| 238 | s.buf.Write(chunkHdr) |
| 239 | |
| 240 | // Write chunk data into streaming buffer |
| 241 | s.buf.Write(s.chunkBuf[:chunkLen]) |
| 242 | |
| 243 | // Write the chunk trailer. |
| 244 | if addCrLf { |
| 245 | s.buf.Write([]byte("\r\n")) |
| 246 | } |
| 247 | |
| 248 | // Reset chunkBufLen for next chunk read. |
| 249 | s.chunkBufLen = 0 |
| 250 | s.chunkNum++ |
| 251 | } |
| 252 | |
| 253 | // addSignedTrailer - adds a trailer with the provided headers, |
| 254 | // then signs a chunk and adds it to output. |
no test coverage detected