17

In RFC5647, NIST SP 800-38D, etc., || is used to denote concatenation. How did that come to be?

In most programming languages || represents "or" and + denotes concatenation and the fact that crypto texts just kind of mixed it up seems to make for an easy gotcha.

neubert
  • 2,969
  • 1
  • 29
  • 58

2 Answers2

16

The origin is set theory and not programming languages. In the context of cryptography, I could describe a set that is $$x_1 \parallel x_2 \parallel \dots \parallel x_n$$ as a concatenation of the series described by $$\parallel_{i=1}^n x_i.$$ Furthermore, it's worth noting that + to a mathematician would suggest that it is a commutative, which might not be true depending on the set (as we could have a set of functions).

b degnan
  • 5,110
  • 1
  • 27
  • 49
9

Some languages like PL/I and Oracle Database SQL indeed use || for string concatenation.

One reason is maybe that + might be confusing when talking about fundamental cryptography, since there is a lot of math involved. The mathematical notation for 'OR' would be reversed caret $\lor$ and the exclusive 'OR', better known as 'XOR' is a circled plus $\oplus$.

But I don't think that there is a specific reason for using || for a string concatenation. If anything then I would presume that someone used it once early and then it has become accustomed until it has become a standard for cryptography.

AleksanderCH
  • 6,511
  • 10
  • 31
  • 64