4

I have never gone really deep into encryption algorithms till date but now I have been put on a project which demands some knowledge on it.

I am using AES-CTR algo and really need to understand what '||' this operation means.

For example: I have the formula which looks like this:

message = AES-CTR<KEY>(SNONCE16||DNONCE16||SID16,NS14).

Basically, key is the encryption key, snonce16 is randomly generated 16 byte on server side, dnonce16 is received from an IOT device and SID16 is its serial no., NS14 is randomly generated encryption nonce on server side.

I get everything, but what does this operation '||' mean . I assumed it was a normal 'or' operation but that might not be the case.

Really need an experts opinion on this.

Thanks.

codemania23
  • 913
  • 11
  • 19

1 Answers1

4

In cryptography the || operation usually means simple concatenation. It's written \| (or, apparently \mathbin\Vert) in TeX and that makes the pipe characters much more narrow, distinguishing it more from other uses.

Related text on the origin of || on the cryptography site is asked and answered here. Apparently it has been adopted from set theory in mathematics.

Note that usually the (encryption) nonce is put in front of the plaintext or ciphertext, rather than the last parameter, so that surprised me a bit.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
  • Thanks Maarten, this was really helpful. I was following an official document and the formula was mentioned as above. So, from code point of view, if i have 3 plain text, say "ab" , "cd" and "da", could you tell me what my end value would look like after the operation. Thanks. – codemania23 Nov 25 '19 at 12:53
  • 1
    Just string concatenation, so "abcdda". Boring, no? – Maarten Bodewes Nov 25 '19 at 12:53
  • Yup, very. I thought, there would be a delimiter. But makes sense, as all the parameters would be of the same byte size. Thanks mate !! – codemania23 Nov 25 '19 at 12:55
  • 1
    Sometimes this kind of concatenation is dangerous in protocols *because* there is no length indication or delimiter, so you don't know which byte was generated by a specific parameter. Was it "AB" || "C" or "A" || "BC"? However, it is often used for parameters that have a known size, because, well, why complicate things? – Maarten Bodewes Nov 25 '19 at 12:57
  • Yes, true. I'll double check if my assumption of size is right then. – codemania23 Nov 25 '19 at 13:00
  • 1
    Probably, because a nonce of only 16 bits doesn't make too much sense either. Note that using a delimiter is a bit tricky if your bytes can have *any* value, you'd have to resort to ugly things like reencoding or escaping to be able to use a delimiter. Using a length indicator makes more sense. – Maarten Bodewes Nov 25 '19 at 15:05