1 Introduction

Rapidly increasing use of international networking offers various new openings for the design and demonstration in the form of digital data. Easy availability and access to digital contents like electronic advertising, video, audio, digital repositories, electronic libraries, web designing etc. arise many security concerns. Copyright violations and plagiarism indicate that current copyright rules are vulnerable to be used for the digital data transfer on internet. Keeping in view, the importance of copyright protection of digital contents, many researchers initiated working in the field of digital watermarking (a process of hiding data inside a digital signal), that is applied to multimedia data such as text, audio, video and digital images.

For the last three decades, different techniques for watermarking are developed and categorized into two main types named as spatial domain [1] and frequency domain techniques [2]. In the spatial domain, the process of watermarking replaces the pixels of the original image (also known as the host image), with the watermark image. However, in the frequency domain the watermarking process is applied on the coefficients’ values of the image. The main feature of both these techniques is to provide digital data the integrity, authentication, copyright protection, broadcast monitoring and most importantly robustness against malicious attacks [3].

Among the aforementioned types of watermarking, spatial domain algorithms offer more capacity to insert watermark but as far as robustness is concerned, frequency domain watermarking is a preferably used technique (see [4] for more details).

Several techniques for digital watermarking in the frequency domain are available in literature including Discrete Cosine Transform (DCT), Discrete Fourier Transform (DFT) [5], Discrete Fractional Fourier Transform (DFRFT) [6] and Discrete Wavelet Transform (DWT) [7, 8]. We, in the proposed framework, apply the Discrete Cosine Transform method to get robust watermarking. It is safe from annoying blocking artifacts as it is not a block-based transform and offers a high degree of freedom for embedding due to its multi-resolution property. DCT may be used with the combination of other transforms to obtain maximum advantages of the properties of other transforms [9, 10].

DCT-based watermarking algorithms have been widely studied [11, 12]. Recently Zhang et al. [13] proposed a digital watermarking scheme based on DCT, that involves two preprocessing steps (before watermark embedding); changing the size of the watermark and scrambling it. However, our proposed method achieves the security targets by using a comparatively simple, direct and more secure approach as compared to [13]. This algorithm is distinguished from the previous work in two senses; firstly, it enhances the security level by utilizing the S-box, secondly, the structural properties of the used local ring contribute to elevate the imperceptibility level of our technique.

In cryptography, S-box plays a vital role in the confusion creating capability of any system. It is the only nonlinear part of any cryptosystem which actually generates confusion and vagueness. Construction of stronger S-boxes is considered as a major focus of recent research as in the last few years S-boxes gained attention in further multimedia applications as well [14, 15].

In this paper, we introduce an application of S-box in digital watermarking in the frequency domain using DCT method. For the construction of our S-box, we utilize the structure of a local ring \({\mathbb{Z}}_{512}\) of size 512 which has a multiplicative subgroup of cardinality 256, formed by the unit elements. The bijection between the group of units and the Galois field \(\varvec{F}_{256}\) leads us to formulate a new S-box by applying a specific map in the corresponding field. This S-box is used to substitute the watermark before the embedding process. By the involvement of S-box, our technique becomes highly secured against any plagiarism and copyright violations. The substituted watermark image is embedded in the DCT-transformed host image, and the watermarked image is obtained by applying the inverse DCT. The algorithm for the extraction of watermark is also discussed which shows non-blind watermark technique.

The material is organized as follows; in Sect. 2, construction of proposed S-box with the help of unit elements of local ring and their bijection with Galois field is outlined. Frequency domain watermarking technique, along with the embedding and extraction algorithm, is described in Sect. 3. Section 4 deals with the performance analyses of the new S-box. Section 5 presents the detailed statistical analyses of the host and watermarked images. In Sect. 6 image processing attacks are used to examine the robustness of the proposed technique. The last section presents the conclusion.

2 Construction of substitution box

This section presents the algebraic algorithm used to structure our S-box. To understand this, we need to go through some basic facts.

A function \(f:\varvec{F}_{{2^{n} }} \to \varvec{F}_{2}\) is called a Boolean function. A vector Boolean \({\text{F}}:\varvec{F}_{{2^{n} }} \to \varvec{F}_{{2^{m} }}\) is defined as \({\text{F}}\left( {\text{x}} \right) = \left( {f_{1} \left( x \right),f_{2} \left( x \right), \ldots ,f_{m} \left( x \right)} \right)\), where \(x = (x_{1} , x_{2} , \ldots , x_{n} ) \in \varvec{F}_{{2^{n} }}\) and each of \(f_{i}\) is called a coordinate Boolean function. An \(n \times n\) S-box is precisely a vector Boolean function: \({\text{S}}:\varvec{F}_{{2^{n} }} \to \varvec{F}_{{2^{m} }}\).

The construction of proposed S-box depends on 3 majors steps; calculation of multiplicative inverses of the elements of the group of units \(U({\mathbb{Z}}_{512} ),\) then the construction of pseudo S-box based on \(U\left( {{\mathbb{Z}}_{512} } \right)\) and in the last step defining one–one correspondence between \(U\left( {{\mathbb{Z}}_{512} } \right)\) and \(\varvec{F}_{256} .\) Consequently, 256 distinct values of S-box are obtained.

First step The set of unit elements \(U\left( {{\mathbb{Z}}_{512} } \right)\) of local ring \({\mathbb{Z}}_{512}\) is given as;

$$\begin{aligned} U\left( {{\mathbb{Z}}_{512} } \right) & = \left\{ {z \in {\mathbb{Z}}_{512} :z \,is\, relatively\, prime \,to\, 512} \right\} \\ & = \left\{ {2t + 1:0 \le t \le 255} \right\} \\ \end{aligned}$$
(1)

Now we introduce map, \(\tau : U\left( {{\mathbb{Z}}_{512} } \right) \to U\left( {{\mathbb{Z}}_{512} } \right)\), defined as

$$\tau \left( z \right) = z^{ - 1}$$
(2)

So we can give the table of multiplicative inverse of each \(2t + 1\) element row-wise (Table 1).

Table 1 Row-wise multiplicative inverse of \(2t + 1\)

Second step Here we need the map, \(\omega\): \(U\left( {{\mathbb{Z}}_{512} } \right)\)\(\to\)\(U\left( {{\mathbb{Z}}_{512} } \right)\) represented by

$$\omega \left( z \right) = cz\quad {\text{where}},\,\,\,\,c \in U\left( {{\mathbb{Z}}_{512} } \right)$$
(3)

For calculation purposes, for instance, we choose \(c = 11\) here, then the composition map

$$\begin{aligned} & v = \omega o\tau :U\left( {{\mathbb{Z}}_{512} } \right) \to U\left( {{\mathbb{Z}}_{512} } \right) \,\,{\text{gives}} \\ & v\left( z \right) = 11 z^{ - 1} \\ \end{aligned}$$
(4)

Third step We define bijective correspondence between \(U\left( {{\mathbb{Z}}_{512} } \right)\) and \(\varvec{F}_{256}\) by

$$l\left( {2t + 1} \right) = \frac{33t + 23}{12t + 9},$$
(5)

where \(0 \le t \le 255.\) The fraction on the left side of Eq. (5) is evaluated by expressing each number in 8-bits format such as 33 = 00100001, 23 = 00010111, 12 = 00001100 and 9 = 00001001. We assign values to “t” corresponding to each of 2t + 1 in Table 2, rewrite it in 8-bits and then apply modular arithmetic as explained in [16, 17].

Table 2 S-box based on \(U\left( {{\mathbb{Z}}_{512} } \right)\)

By the help of these calculations, Table 2 is transformed into an \(8 \times 8\) proposed S-box.

3 Performance analysis of the proposed S-box

In this section, the essential performance parameters are inspected for the newly generated S-box. The assessment of the projected S-box guarantees its competence and strength [18]. In this article, best available tests are selected to assure the strength of the S-box. It includes bit independence criterion (BIC), linear approximation probability (LP), differential approximation probability (DP), nonlinearity, bit independence criterion (BIC) and strict avalanche criterion. It is proved that the new S-box fulfills all the requirements to be used in further applications. The subsections below describe the required properties in detail (Table 3).

Table 3 Proposed S-box

3.1 Strict avalanche criterion

It is the highly-desired property of an S-box that single input deviation produces series of variations in the substitution- permutation network [19, 20].

If we make a single input-bit change, that is, we have two \(n\)-tuples \(x\) and \(y \in F_{2}^{n}\) that differ at only one coordinate (say ith coordinate). Mathematically, let \(x = \left( {x_{1} , x_{2} , \ldots .x_{n} } \right)\) and \(y = x \oplus \tau_{i}\), where \(\tau_{i}\) is an \(n\)-tuple, with 1 at \(ith\) position and zeros elsewhere (so that \(x\) and \(y\) differ at \(ith\) coordinate only. Let us consider an arbitrary component Boolean function \(f_{k}\). Let \(f_{k} \left( x \right)\) and \(f_{k} \left( {x \oplus \tau_{i} } \right)\) be the outputs of \(f_{k}\) for a single input-bit change. We denote the corresponding output difference by \(\xi_{k}^{i}\), i.e.

$$\xi_{k}^{i} = f_{k} \left( x \right) \oplus f_{k} \left( {x \oplus \tau_{i} } \right)$$

Let \(d_{i}\) represents the number of \(n\)-tuples \(x \in\)\(F_{2}^{n} ,\) out of the total \(2^{n}\) tuples in \(F_{2}^{n}\), for which \(f_{k} \left( x \right) \ne f_{k} \left( {x \oplus \tau_{i} } \right)\), then the avalanche probability \(P_{k}^{i}\) for the \(kth\) Boolean function is given by;

$$P_{k}^{i} = \frac{{d_{i} }}{{2^{n} }}$$

\(P_{k}^{i}\) can be interpreted as the probability of change of the output of \(f_{k}\), when only \(ith\) bit of input \(x\) is complemented. The strict avalanche criterion \(P_{k}^{i}\) must be \(\frac{1}{2}, \,\,\forall 0 \le i,\,\, k \le n\).

Table 4 shows the results of strict avalanche criterion and Fig. 1 provides the comparison of the proposed S-box with the prevailing S-boxes such as Gray, APA, residue prime, S8, Xyi and state of the art, AES S-box. The average value of the strict avalanche criterion comes out to be 0.5039.

Table 4 Strict avalanche criterion of substitution box
Fig. 1
figure 1

Strict avalanche criteria of various S-boxes

3.2 Bit independence criterion

The makeup for a single plaintext bit is the basic feature of bit independence criterion (BIC). The independent behavior of the pair of variables and the variations of input bits are considered as important factors of bit independence criterion. In bit independence criterion, input bits are transformed exclusively, and then output results are scrutinized for their independency [19, 21]. Bit independence has great worth in cryptographic structures. The goal of reaching the maximum complexity and perplexity in a system can be achieved through this property of increasing independence between the bits. Table 5 presents bit independence of nonlinearity and Table 6 show the comparison of the minimum value, the average value and the square deviation of the proposed S-box with different S-boxes. The minimum value of proposed S-box is 96, the average value is 103.25 and square deviation is 2.849. Figure 2 is a pictorial representation of the comparison of numerical results of BIC applied on different S-boxes.

Table 5 The BIC of nonlinearity of proposed S-box changed
Table 6 Bit independence criterion of various substitution boxes
Fig. 2
figure 2

Bit independence criterion of various substitution boxes

3.3 Nonlinearity

Nonlinearity analysis measures the distance of the reference function from all of the affine functions. Non-linearity criterion outlines the total number of bits that must be altered in the truth table of a Boolean function to get close to the nearby affine function. These calculations are given as

$$N_{g} = 2^{m - 1} \left( {1 - 2^{ - m} max\left| {S_{\left( g \right)} \left( w \right)} \right|} \right)$$
(6)

where

(7)

represents the Walsh Spectrum. For more details and calculation process see [21]. The average nonlinearity of our S-box is 104.375 that is reasonably acceptable. The nonlinearity measures of the coordinate functions of the proposed S-box and different S-boxes are given in Table 7. Figure 3 is the graphical representation of the nonlinearity comparison.

Table 7 The nonlinearity of coordinate functions of different substitution boxes
Fig. 3
figure 3

Nonlinearity of proposed and other S-boxes

3.4 Linear approximation probability

The unevenness of an event is calculated in linear approximation method. The maximum value of imbalance of the outcome is also attained through this test. The parity of input and output bits is given by the masks \(\varGamma_{l}\) and \(\varGamma_{m}\) respectively. It is given as

$$LP = \mathop {\hbox{max} }\limits_{{\varGamma_{l} ,\varGamma_{m} \ne 0}} \left| {\frac{{\# \left\{ {z/z \bullet \varGamma_{l} = S\left( z \right) \bullet \varGamma_{m} } \right\}}}{{2^{l} }} - \frac{1}{2}} \right|$$
(8)

where \(z\) is the set of all possible inputs, the total number of elements is \(2^{l}\). The Linear approximation probability of the proposed S-box is 0.1094. The results are compared in Table 8. It is evident from these results that our S-box shows resistance to linear attacks. The graphical representation of the linear approximation of proposed S-box and different S-boxes is given in Fig. 4.

Table 8 Linear approximation probability analyses of different S-boxes
Fig. 4
figure 4

Comparison of linear approximation probability

3.5 Differential approximation probability

For further analysis, we rely on the differential approximation probability test which determines the differential uniformity demonstrated by an S-box. The differential approximation probability is measured by analyzing every input bit and establishing the fact that uniform mapping is ensured. Mathematically, it is given as

$$D_{{P^{s} }} \left( {\Delta x \to \Delta y} \right) = \frac{{\left[ {\# \left\{ {x\varepsilon X/S\left( l \right) \oplus S\left( {x \oplus \Delta x} \right) = \Delta y} \right\}} \right] }}{{2^{m} }}$$
(9)

The results of odds of differential by applying input and output differentials are given in Table 9. The graphical analyses of proposed S-box and some well-known S-boxes are also shown in Fig. 5.

Table 9 Differential approximation probability of proposed S-box
Fig. 5
figure 5

Comparison of differential approximation probability

4 Watermarking algorithm using S-box

The flow chart of the new technique of watermarking using S-box and frequency domain watermarking is depicted in Fig. 1. By utilizing the multiplicative subgroup of unit elements \(U({\mathbb{Z}}_{512}\)) of the local ring \({\mathbb{Z}}_{512}\), we propose a new S-box which is based on the special algebraic structure of a local ring and its relation with the Galois field. The newly developed S-box possesses reasonably acceptable performance indices as discussed in the previous section. By the help of this S-box, we substitute the watermark image first. This altered and secured watermark is then embedded into the DCT-transformed version of the original image. In frequency domain, almost all portions of image observe the change as the watermark is inserted in low or middle frequencies and low-frequency components contain the larger portion of energy. Due to special features of discrete cosine transform, we are applying the frequency domain technique using DCT.

Fourier series provides us the establishment of various transforms including discrete cosine transform (DCT). DCT transforms an image to the frequency domain by compression which is obtained through data quantization. This transform only uses the real part of the Fourier complex kernel and neglect complex part. The main information of the original image is concentrated into the smallest low-frequency coefficient with the help of 2D-DCT. Moreover, due to this transformation, the effect of image blocking is minified, which shows good interaction between the information centralizing and the computing complications. The embedding process is strengthened with the help of secure S-box and this altered watermark is than embedded into DCT-converted host image. For extraction of the watermark, the original host image is needed as it is the non-blind technique of frequency domain. Figures 6 and 7 represent the process of embedding and extraction of the watermark respectively.

Fig. 6
figure 6

Embedding of S-box substituted watermark in original image

Fig. 7
figure 7

Extraction of watermark

Fig. 8
figure 8

Host images. a Lena. b Baboon. c Peppers

4.1 Embedding and extraction of watermark

Let the host image is of size \(H1 \times H2\) and is given by \(H = \left\{ {h\left( {x, y} \right), \,1 \le x \le H1,\, 1 \le y \le H2} \right\}\) and the watermark image is of size \(W1 \times W2\) be denoted as \(W = \{ w\left( {i, j } \right), 1 \le i \le w1, 1 \le j \le\) W2} and \(\left( {x,y} \right)\), \(\left( {i, j } \right)\) represent the pixel coordinates of original host image and gray watermark image respectively, If \(P\) denotes the total number of binary bits of gray level image pixels than \(h(x, y\)) and \(w\left( {i, j} \right)\) is given by \(\{ 0,1, \ldots ,2L - 1\}\). The substitution of the frequency domain is almost same as that in spatial domain with an exception that the watermark is embedded into frequency coefficients of the transformed image. In this article, the scheme becomes more secure as the watermark is substituted with algebraic S-box. This provides more strength to our technique and copy right protection to support our claim at any forum. The watermark is then inserted into DCT-transformed image where we consider positive integral parts of DCT coefficients (neglecting the sign of negative DCT coefficients) and replace the LSBs of DCT coefficient with MSBs of the altered watermark. After applying IDCT on the result we attain the final watermarked image.

In embedding scheme, it must be clear that the S-box, is another hidden truth to counterfeit any plagiarism attempt. Moreover, this provides a strong mathematical foundation to our technique. Figure 8(a)–(c) represent the gray level host images of Lena, Baboon and Peppers respectively. Figure 9 represents the watermark image. The altered watermark, under the application of S-box is depicted in Fig. 10, however, Fig. 11(a)–(c) illustrate the watermarked images of Lena, Baboon and Peppers, after applying the proposed DCT-based watermarking scheme in the frequency domain. The visual results witness that the final watermarked images have the identical appearance as in Fig. 8 of the original images.

Fig. 9
figure 9

Watermark

Fig. 10
figure 10

S-box substituted watermark

Fig. 11
figure 11

Watermarked images. a Lena. b Baboon. c Peppers

Following the inverse process of embedding, it is possible to extract the watermark image from the original image. The watermarked image is then subjected to DCT and extraction of the original image is done by replacing 4 LSBs of DCT watermarked image with original values. By this process, we are able to extract the watermark from the original image. The extraction process involves the inverse S-box algorithm as well. Figure 12 represent the extracted S-box substituted image and Fig. 13 shows the successfully extracted watermark. The extracted original images of Lena, baboon and Peppers are represented in Fig. 14(a)–(c) respectively.

Fig. 12
figure 12

Extracted S-box substituted watermark

Fig. 13
figure 13

Extracted watermark

Fig. 14
figure 14

Extracted images. a Lena. b Baboon. c Peppers

5 Simulation results and statistical analysis of host and watermarked image

The assessment of both the original image and the s-box substituted, watermarked image with certain statistical tests is performed in this section. We perform frequently used tests including homogeneity, contrast, correlation, entropy, energy, mean square error and peak signal to noise ratio on both the images. These analyses are made on 256 × 256 image of Lena, baboon and pepper along with 50 × 50 watermark image. The results of all above-mentioned analyses are presented in Table 10 and Fig. 15.

Table 10 Statistical analyses of host image and watermarked image
Fig. 15
figure 15

Comparison of MLC for different images

5.1 Homogeneity

Gray level co-occurrence matrix (GLCM) indicates the ability of combinations of pixel brightness results in tabular form. The closeness of the distribution in the (GLCM) to its diagonal is measured in homogeneity. GLCM table gives gray levels frequency. The homogeneity is given as:

$$Hom = \sum {\frac{{p\left( {i,j} \right)}}{{1 + \left| {i - j} \right|}}}$$
(10)

5.2 Contrast

The Contrast analysis is used to measure the sensitivity of the image textures in relation to intensity alterations. It is defined as

$$C = \sum {\left| {i - j} \right|^{2} p(i,j)}$$
(11)

5.3 Energy

For the energy analysis, initially squares of all \(ith\) row and \(jth\) column values of gray pixels is calculated and then added to get mathematical representation given as follows

$$E = \sum {p\left( {i,j} \right)^{2} }$$
(12)

5.4 Entropy

Entropy helps to determine whether the approximation of the digital image is same as the original image. Entropy specifies the uncertainty of the digital image as it is the magnitude of the randomness. Mathematically,

$$C = - \sum { p\left( {x_{i} } \right)} log_{2} p\left( {x_{i} } \right)$$
(13)

5.5 Correlation

The similarity between the original image and the watermarked image helps to analyze the quality of scheme which is obtained from correlation. Mathematically it is represented as:

$$Corr = \sum {\frac{{\left( {i - \mu i} \right)\left( {j - \mu j} \right)p\left( {i,j} \right)}}{{\sigma_{{i\sigma_{j} }} }}}$$
(14)

In above equation, \(\mu\) and \(\sigma\) denote the mean and the standard deviation respectively and P(\(i,j\)) represents the \(ith\) row and \(jth\) column pixel value.

5.6 Mean squared error

The dissimilarity between two digital images is calculated with the help of the mean squared error. Table 11 gives the result of MSE. Mathematically it is given by the equation

$$MSE = \frac{1}{n}\sum {\left( {x_{i } - x_{i}^{* } } \right)^{2} }$$
(15)
Table 11 MSE and PSNR values of proposed watermarking technique

5.7 Peak signal to noise ratio

The logarithm of the ratio between the signal strength and difference between the images (MSE) gives peak signal to noise ratio. It provides the best relative statistical analysis. Table 11 gives the result of PSNR. It is given as:

$$PSNR = 10 log_{10} \frac{{MAX_{I}^{2} }}{MSE}$$
(16)

5.8 Complexity analysis

For the application of the proposed technique, the most important factors are the improved security and the embedding, extraction speed of watermark along with the space complexity. In this regard, speed analysis is performed with the help of MATLAB 7.9.0 (R2009b) on a laptop having Windows 7 working structure, Intel(R) Core(TM) i5-2520 M, CPU@ 2.50 GHz and RAM of 4 GB. One can see that the speed of our embedding and extraction process is pretty close to the other DCT-based schemes, however the security level attained by the proposed scheme is highly improved than the recently known techniques. It is worth mentioning that the sequence of operations used for the proposed algorithm requires no additional space. Table 12 provides elapsed time for embedding and extraction of watermark with different image sizes and picture qualities.

Table 12 Elapsed time for Embedding and Extraction of watermark

6 Robustness test based on image processing operations

The mathematical approximation of two watermarks is the similarity between the extracted and the original watermark [22]. High correlation between the both leads to robustness. The close correlation between two watermarks is observed when the result of similarity is on the higher side. It is represented as,

$$Sim = \frac{{\sum {t_{i} .s_{i} } }}{{\sqrt {\sum {t_{i}^{2} } .\sum {s_{i}^{2} } } }}$$
(17)

where \(t_{i } ,s_{i }\) represents the corresponding \(ith\) element of the extracted and the original watermark respectively. The numerical value for confidence measure in our simulation results is 99.92. It demonstrates the ideal correlation between extracted and original watermarks. The watermarked image and extracted watermark are gone through well-known image processing operations which are given in the following subsections. Similarity analysis of different images is given in Table 13.

Table 13 Similarity analysis of different Images

6.1 Noise attack

The watermark image can be attacked by different noise attacks. Here we add salt noise. Gaussian, Poisson and speckle can also be used for this purpose.

6.2 Compression attack

Joint Photographic Experts Group (JPEG) is measured for compression attack.

6.3 Cropping attack

In cropping attack either extracted image is distorted or offers fewer information than the original image. The outcomes of all image processing attacks are given in Table 14 and Figs. 15, 16 and 17 represent the compression, noise and cropping attacks respectively.

Table 14 Confidence measure values against different image processing attacks
Fig. 16
figure 16

Pictures of image processing effects. Compression attack

Fig. 17
figure 17

Pictures of image processing effects. Salt and Pepper attack

7 Conclusion

With certain weaknesses, the best-offered technique for safe copyrights of multimedia data is digital watermarking. In this paper, a new idea is presented for watermarking that mainly relies on a newly designed \(8 \times 8\) S-box from a local ring instead of a Galois field. The involvement of S-box in the scheme, where we substitute the values of watermark image, not only develops confusion in understanding the used scheme but also provides more security and support to our argument for copy right protection of digital data. This technique of watermarking is based on frequency domain Discrete Cosine Transform. The complexity of the algebraic structure of the S-box and then frequency domain technique makes almost impossible to identify watermark. Moreover, the outcomes of statistical analyses and robustness tests really support the new idea of watermarking. The numeric results of similarity, after the application of the image processing tests, lie in the range 40–79%, (78.92% in our case) which makes us conclude that our technique is a semi-fragile watermarking technique (Fig. 18).

Fig. 18
figure 18

Pictures of image processing effects. Cropping attack