Skip to content

Commit bf54a60

Browse files
authored
chore: Update comment to be correct (#282)
The sequence number starts at 1. 0 is not valid.
1 parent 998344c commit bf54a60

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

modules/serialize/src/serialize_factory.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ export function serializeFactory (fromUtf8: (input: any) => Uint8Array) {
4343
}
4444

4545
function frameIv (ivLength: IvLength, sequenceNumber: number) {
46-
/* Precondition: sequenceNumber must conform to the specification. i.e. 0 - (2^32 - 1) */
46+
/* Precondition: sequenceNumber must conform to the specification. i.e. 1 - (2^32 - 1)
47+
* The sequence number starts at 1
48+
* https://github.com/awslabs/aws-encryption-sdk-specification/blob/master/data-format/message-body.md#sequence-number
49+
*/
4750
needs(sequenceNumber > 0 && SequenceIdentifier.SEQUENCE_NUMBER_END >= sequenceNumber, 'sequenceNumber out of bounds')
4851

4952
const buff = new Uint8Array(ivLength)

modules/serialize/test/serialize_factory.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('serializeFactory:frameIv', () => {
3030
expect(test).to.deep.equal(fixtures.basicFrameIV())
3131
})
3232

33-
it('Precondition: sequenceNumber must conform to the specification. i.e. 0 - (2^32 - 1)', () => {
33+
it('Precondition: sequenceNumber must conform to the specification. i.e. 1 - (2^32 - 1)', () => {
3434
const fromUtf8 = () => { throw new Error('not used') }
3535
const { frameIv } = serializeFactory(fromUtf8)
3636
expect(() => frameIv(12, 0)).to.throw()

0 commit comments

Comments
 (0)