Bug Summary

File:crypto/ecb_enc.c
Warning:line 101, column 10
Although the value stored to 't' is used in the enclosing expression, the value is never actually read from 't'

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd7.0 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name ecb_enc.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -relaxed-aliasing -fno-rounding-math -mconstructor-aliases -ffreestanding -mcmodel=kernel -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -target-feature -sse2 -target-feature -sse -target-feature -3dnow -target-feature -mmx -target-feature +save-args -disable-red-zone -no-implicit-float -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -nostdsysteminc -nobuiltininc -resource-dir /usr/local/lib/clang/13.0.0 -I /usr/src/sys -I /usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -I /usr/src/sys/arch -I /usr/src/sys/dev/pci/drm/include -I /usr/src/sys/dev/pci/drm/include/uapi -I /usr/src/sys/dev/pci/drm/amd/include/asic_reg -I /usr/src/sys/dev/pci/drm/amd/include -I /usr/src/sys/dev/pci/drm/amd/amdgpu -I /usr/src/sys/dev/pci/drm/amd/display -I /usr/src/sys/dev/pci/drm/amd/display/include -I /usr/src/sys/dev/pci/drm/amd/display/dc -I /usr/src/sys/dev/pci/drm/amd/display/amdgpu_dm -I /usr/src/sys/dev/pci/drm/amd/pm/inc -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu11 -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu12 -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/hwmgr -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/smumgr -I /usr/src/sys/dev/pci/drm/amd/display/dc/inc -I /usr/src/sys/dev/pci/drm/amd/display/dc/inc/hw -I /usr/src/sys/dev/pci/drm/amd/display/dc/clk_mgr -I /usr/src/sys/dev/pci/drm/amd/display/modules/inc -I /usr/src/sys/dev/pci/drm/amd/display/modules/hdcp -I /usr/src/sys/dev/pci/drm/amd/display/dmub/inc -I /usr/src/sys/dev/pci/drm/i915 -D DDB -D DIAGNOSTIC -D KTRACE -D ACCOUNTING -D KMEMSTATS -D PTRACE -D POOL_DEBUG -D CRYPTO -D SYSVMSG -D SYSVSEM -D SYSVSHM -D UVM_SWAP_ENCRYPT -D FFS -D FFS2 -D FFS_SOFTUPDATES -D UFS_DIRHASH -D QUOTA -D EXT2FS -D MFS -D NFSCLIENT -D NFSSERVER -D CD9660 -D UDF -D MSDOSFS -D FIFO -D FUSE -D SOCKET_SPLICE -D TCP_ECN -D TCP_SIGNATURE -D INET6 -D IPSEC -D PPP_BSDCOMP -D PPP_DEFLATE -D PIPEX -D MROUTING -D MPLS -D BOOT_CONFIG -D USER_PCICONF -D APERTURE -D MTRR -D NTFS -D HIBERNATE -D PCIVERBOSE -D USBVERBOSE -D WSDISPLAY_COMPAT_USL -D WSDISPLAY_COMPAT_RAWKBD -D WSDISPLAY_DEFAULTSCREENS=6 -D X86EMU -D ONEWIREVERBOSE -D MULTIPROCESSOR -D MAXUSERS=80 -D _KERNEL -D CONFIG_DRM_AMD_DC_DCN3_0 -O2 -Wno-pointer-sign -Wno-address-of-packed-member -Wno-constant-conversion -Wno-unused-but-set-variable -Wno-gnu-folding-constant -fdebug-compilation-dir=/usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -o /usr/obj/sys/arch/amd64/compile/GENERIC.MP/scan-build/2022-01-12-131800-47421-1 -x c /usr/src/sys/crypto/ecb_enc.c
1/* $OpenBSD: ecb_enc.c,v 1.6 2015/12/10 21:00:51 naddy Exp $ */
2
3/* lib/des/ecb_enc.c */
4/* Copyright (C) 1995 Eric Young (eay@mincom.oz.au)
5 * All rights reserved.
6 *
7 * This file is part of an SSL implementation written
8 * by Eric Young (eay@mincom.oz.au).
9 * The implementation was written so as to conform with Netscapes SSL
10 * specification. This library and applications are
11 * FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
12 * as long as the following conditions are aheared to.
13 *
14 * Copyright remains Eric Young's, and as such any Copyright notices in
15 * the code are not to be removed. If this code is used in a product,
16 * Eric Young should be given attribution as the author of the parts used.
17 * This can be in the form of a textual message at program startup or
18 * in documentation (online or textual) provided with the package.
19 *
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions
22 * are met:
23 * 1. Redistributions of source code must retain the copyright
24 * notice, this list of conditions and the following disclaimer.
25 * 2. Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 * 3. All advertising materials mentioning features or use of this software
29 * must display the following acknowledgement:
30 * This product includes software developed by Eric Young (eay@mincom.oz.au)
31 *
32 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
36 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 * SUCH DAMAGE.
43 *
44 * The licence and distribution terms for any publically available version or
45 * derivative of this code cannot be changed. i.e. this code cannot simply be
46 * copied and put under another distribution licence
47 * [including the GNU Public Licence.]
48 */
49
50#include "des_locl.h"
51#include "spr.h"
52
53void
54des_encrypt2(u_int32_t *data, des_key_schedule ks, int encrypt)
55{
56 register u_int32_t l, r, t, u;
57#ifdef DES_USE_PTR
58 register unsigned char *des_SP=(unsigned char *)des_SPtrans;
59#endif
60 register int i;
61 register u_int32_t *s;
62
63 u = data[0];
64 r = data[1];
65
66 /* Things have been modified so that the initial rotate is
67 * done outside the loop. This required the
68 * des_SPtrans values in sp.h to be rotated 1 bit to the right.
69 * One perl script later and things have a 5% speed up on a sparc2.
70 * Thanks to Richard Outerbridge <71755.204@CompuServe.COM>
71 * for pointing this out. */
72 l = (r << 1) | (r >> 31);
73 r = (u << 1) | (u >> 31);
74
75 /* clear the top bits on machines with 8byte longs */
76 l &= 0xffffffffL;
77 r &= 0xffffffffL;
78
79 s = (u_int32_t *) ks;
80 /* I don't know if it is worth the effort of loop unrolling the
81 * inner loop */
82 if (encrypt) {
83 for (i = 0; i < 32; i += 4) {
84 D_ENCRYPT(l, r, i + 0){ u=(r^s[i + 0 ]); t=r^s[i + 0 +1]; t=((t>>4L)+(t<<
28L)); l^= des_SPtrans[1][(t )&0x3f]| des_SPtrans[3][(t>>
8L)&0x3f]| des_SPtrans[5][(t>>16L)&0x3f]| des_SPtrans
[7][(t>>24L)&0x3f]| des_SPtrans[0][(u )&0x3f]| des_SPtrans
[2][(u>> 8L)&0x3f]| des_SPtrans[4][(u>>16L)&
0x3f]| des_SPtrans[6][(u>>24L)&0x3f]; }
; /* 1 */
85 D_ENCRYPT(r, l, i + 2){ u=(l^s[i + 2 ]); t=l^s[i + 2 +1]; t=((t>>4L)+(t<<
28L)); r^= des_SPtrans[1][(t )&0x3f]| des_SPtrans[3][(t>>
8L)&0x3f]| des_SPtrans[5][(t>>16L)&0x3f]| des_SPtrans
[7][(t>>24L)&0x3f]| des_SPtrans[0][(u )&0x3f]| des_SPtrans
[2][(u>> 8L)&0x3f]| des_SPtrans[4][(u>>16L)&
0x3f]| des_SPtrans[6][(u>>24L)&0x3f]; }
; /* 2 */
86 }
87 } else {
88 for (i = 30; i > 0; i -= 4) {
89 D_ENCRYPT(l, r, i - 0){ u=(r^s[i - 0 ]); t=r^s[i - 0 +1]; t=((t>>4L)+(t<<
28L)); l^= des_SPtrans[1][(t )&0x3f]| des_SPtrans[3][(t>>
8L)&0x3f]| des_SPtrans[5][(t>>16L)&0x3f]| des_SPtrans
[7][(t>>24L)&0x3f]| des_SPtrans[0][(u )&0x3f]| des_SPtrans
[2][(u>> 8L)&0x3f]| des_SPtrans[4][(u>>16L)&
0x3f]| des_SPtrans[6][(u>>24L)&0x3f]; }
; /* 16 */
90 D_ENCRYPT(r, l, i - 2){ u=(l^s[i - 2 ]); t=l^s[i - 2 +1]; t=((t>>4L)+(t<<
28L)); r^= des_SPtrans[1][(t )&0x3f]| des_SPtrans[3][(t>>
8L)&0x3f]| des_SPtrans[5][(t>>16L)&0x3f]| des_SPtrans
[7][(t>>24L)&0x3f]| des_SPtrans[0][(u )&0x3f]| des_SPtrans
[2][(u>> 8L)&0x3f]| des_SPtrans[4][(u>>16L)&
0x3f]| des_SPtrans[6][(u>>24L)&0x3f]; }
; /* 15 */
91 }
92 }
93 l = (l >> 1) | (l << 31);
94 r = (r >> 1) | (r << 31);
95 /* clear the top bits on machines with 8byte longs */
96 l &= 0xffffffffL;
97 r &= 0xffffffffL;
98
99 data[0] = l;
100 data[1] = r;
101 l = r = t = u = 0;
Although the value stored to 't' is used in the enclosing expression, the value is never actually read from 't'
102}