├── Status report.pptx ├── README.md ├── koggestoneadder_1024bit.v ├── koggestoneadder_16bit_testbench.v ├── koggestoneadder_16bit.v ├── montgomery1024.v └── LICENSE /Status report.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p4r4xor/Montgomery1024/HEAD/Status report.pptx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Montgomery1024 2 | Verilog implementation of 1024 bit Montgomery Multiplication/Exponentiation. 3 | 4 | S19EC6.201 Digital Signal Processing Coursework 5 | 6 | Course Instructor: Prof. Syed Azeemuddin, IIIT Hyderabad 7 | 8 | This project was intended for faster implementation of hardware cryptographic protocols, RSA, DSA and DH for example. 9 | 10 | We've rolled out our own [Hybrid Montgomery algorithm](https://eprint.iacr.org/2013/882.pdf) and successfully reduced the design latency by a whopping 34% in accordance with multiple IEEE papers. We've decided to go with Kogge Stone adder and had to sacrifice Area and Power for Time, but yet the total expected output was almost identical with the unoptimized algorithm. 11 | ``` 12 | The Kogge stone adder cancels out the unoptimized Montgomery and hence, a win-win situation for everyone! 13 | ``` 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /koggestoneadder_1024bit.v: -------------------------------------------------------------------------------- 1 | `timescale 1ns / 1ps 2 | 3 | module adder( 4 | input wire clk, 5 | input wire resetn, 6 | input wire start, 7 | input wire subtract, 8 | input wire shift, 9 | input wire [1024:0] in_a, 10 | input wire [1024:0] in_b, 11 | output wire [1025:0] result, 12 | output wire done 13 | ); 14 | 15 | reg[1024:0] a, b; 16 | reg c, d; 17 | reg [1229:0] s; 18 | reg [3:0]cntr; 19 | wire [205:0] reg_result; 20 | assign reg_result = a[204:0] + b[204:0] + c; 21 | reg[1:0]state; 22 | 23 | always @(posedge clk) 24 | begin 25 | if (resetn == 0) 26 | begin 27 | a <= 0; 28 | b <= 0; 29 | c <= 0; 30 | cntr <= 0; 31 | d <= 0; 32 | s<=0; 33 | state<=2'b00; 34 | end 35 | else 36 | begin 37 | 38 | case(state) 39 | //Idle state 40 | 2'b00: begin 41 | a <= in_a; 42 | c<=subtract; 43 | cntr <= 0; 44 | d <= 0; 45 | if (subtract==1) 46 | begin 47 | b<=~in_b; 48 | end 49 | else 50 | begin 51 | b <= in_b; 52 | end 53 | state[0] <= start; 54 | end 55 | //calculate state 56 | 2'b01: begin 57 | cntr<=cntr+1; 58 | s <= {reg_result[204:0], s[1229:205]}; 59 | c<=reg_result[205]; 60 | a <= a>>205; 61 | b <= b>>205; 62 | if(cntr==5) 63 | begin 64 | state<=2'b10; 65 | end 66 | else 67 | begin 68 | state<=2'b01; 69 | end 70 | end 71 | //latest bit state 72 | 2'b10: begin 73 | s[1025]<=s[1025] ^ subtract; 74 | d<=1'b1; 75 | state<=2'b00; 76 | end 77 | endcase 78 | end 79 | end 80 | 81 | assign result = s[1025:0]; 82 | assign done = d; 83 | endmodule -------------------------------------------------------------------------------- /koggestoneadder_16bit_testbench.v: -------------------------------------------------------------------------------- 1 | module tb_KSA8; 2 | wire [7:0] sum; 3 | wire cout; 4 | reg [7:0] a, b; 5 | reg cin; 6 | 7 | KSA8 ksa8(sum[7:0], cout, a[7:0], b[7:0]); 8 | 9 | initial 10 | begin 11 | $display("a |b ||cout|sum "); 12 | end 13 | 14 | initial 15 | begin 16 | $monitor("%b|%b||%b |%b", a[7:0], b[7:0], cout, sum[7:0]); 17 | end 18 | 19 | initial 20 | begin 21 | a=8'b10100000; b=8'b10100000; 22 | #10 a=8'b01011000; b=8'b11110100; 23 | #10 a=8'b00111101; b=8'b00001111; 24 | #10 a=8'b11001010; b=8'b11001000; 25 | #10 a=8'b10100110; b=8'b11110100; 26 | #10 a=8'b11110011; b=8'b11001100; 27 | #10 a=8'b11110011; b=8'b01010111; 28 | 29 | end 30 | endmodule 31 | 32 | module tb_KSA16; 33 | wire [15:0] sum; 34 | wire cout; 35 | reg [15:0] a, b; 36 | reg cin; 37 | 38 | KSA16 ksa16(sum[15:0], cout, a[15:0], b[15:0]); 39 | 40 | initial 41 | begin 42 | $display("a |b ||cout|sum "); 43 | end 44 | 45 | initial 46 | begin 47 | $monitor("%b|%b||%b |%b", a[15:0], b[15:0], cout, sum[15:0]); 48 | end 49 | 50 | initial 51 | begin 52 | a=16'b1010000010100000; b=16'b1010000010100000; 53 | #10 a=16'b0101100011110100; b=16'b1111010011110100; 54 | #10 a=16'b0000111100111101; b=16'b0000111100001111; 55 | #10 a=16'b1100100011001010; b=16'b1100100011001010; 56 | 57 | end 58 | endmodule 59 | 60 | 61 | module tb_KSA32; 62 | wire [31:0] sum; 63 | wire cout; 64 | reg [31:0] a, b; 65 | reg cin; 66 | 67 | KSA32 ksa32(sum[31:0], cout, a[31:0], b[31:0]); 68 | 69 | initial 70 | begin 71 | $display("a|b||cout|sum"); 72 | end 73 | 74 | initial 75 | begin 76 | $monitor("%b|%b||%b|%b", a[31:0], b[31:0], cout, sum[31:0]); 77 | end 78 | 79 | initial 80 | begin 81 | a='b10100000101000001111111111111111; b='b10100000101111111111111111100000; 82 | #10 a='b01011000111111111111111111110100; b='b11110100111101001111111111111111; 83 | #10 a='b11111111111111110000111100111101; b='b00001111000011111111111111111111; 84 | #10 a='b11011111111111111110100011001010; b='b11001111111111111111100011001010; 85 | 86 | end 87 | endmodule 88 | 89 | module tb_KSA64; 90 | wire [63:0] sum; 91 | wire cout; 92 | reg [63:0] a, b; 93 | reg cin; 94 | 95 | KSA64 ksa64(sum[63:0], cout, a[63:0], b[63:0]); 96 | 97 | initial 98 | begin 99 | $display("a|b||cout|sum"); 100 | end 101 | 102 | initial 103 | begin 104 | $monitor("%d|%d||%d|%h", a[63:0], b[63:0], cout, sum[63:0]); 105 | end 106 | 107 | initial 108 | begin 109 | a=64'd998; b=64'd128; 110 | #10 a=64'd9998; b=64'd9028; 111 | #10 a=64'hfaaaaaaafaaaaaaa; b=64'hfaaaaaaadbbbbbbb; 112 | 113 | end 114 | endmodule -------------------------------------------------------------------------------- /koggestoneadder_16bit.v: -------------------------------------------------------------------------------- 1 | module BigCircle(output G, P, input Gi, Pi, GiPrev, PiPrev); 2 | 3 | wire e; 4 | and #(1) (e, Pi, GiPrev); 5 | or #(1) (G, e, Gi); 6 | and #(1) (P, Pi, PiPrev); 7 | 8 | endmodule 9 | 10 | module SmallCircle(output Ci, input Gi); 11 | 12 | buf #(1) (Ci, Gi); 13 | 14 | endmodule 15 | 16 | module Square(output G, P, input Ai, Bi); 17 | 18 | and #(1) (G, Ai, Bi); 19 | xor #(2) (P, Ai, Bi); 20 | 21 | endmodule 22 | 23 | module Triangle(output Si, input Pi, CiPrev); 24 | 25 | xor #(2) (Si, Pi, CiPrev); 26 | 27 | endmodule 28 | 29 | module KSA8(output [7:0] sum, output cout, input [7:0] a, b); 30 | 31 | wire cin = 1'b0; 32 | wire [7:0] c; 33 | wire [7:0] g, p; 34 | Square sq[7:0](g, p, a, b); 35 | 36 | // first line of circles 37 | wire [7:1] g2, p2; 38 | SmallCircle sc0_0(c[0], g[0]); 39 | BigCircle bc0[7:1](g2[7:1], p2[7:1], g[7:1], p[7:1], g[6:0], p[6:0]); 40 | 41 | // second line of circle 42 | wire [7:3] g3, p3; 43 | SmallCircle sc1[2:1](c[2:1], g2[2:1]); 44 | BigCircle bc1[7:3](g3[7:3], p3[7:3], g2[7:3], p2[7:3], g2[5:1], p2[5:1]); 45 | 46 | // third line of circle 47 | wire [7:7] g4, p4; 48 | SmallCircle sc2[6:3](c[6:3], g3[6:3]); 49 | BigCircle bc2_7(g4[7], p4[7], g3[7], p3[7], g3[3], p3[3]); 50 | 51 | // fourth line of circle 52 | SmallCircle sc3_7(c[7], g4[7]); 53 | 54 | // last line - triangles 55 | Triangle tr0(sum[0], p[0], cin); 56 | Triangle tr[7:1](sum[7:1], p[7:1], c[6:0]); 57 | 58 | // generate cout 59 | buf #(1) (cout, c[7]); 60 | 61 | endmodule 62 | 63 | module KSA16(output [15:0] sum, output cout, input [15:0] a, b); 64 | 65 | wire cin = 1'b0; 66 | wire [15:0] c; 67 | wire [15:0] g, p; 68 | Square sq[15:0](g, p, a, b); 69 | 70 | // first line of circles 71 | wire [15:1] g2, p2; 72 | SmallCircle sc0_0(c[0], g[0]); 73 | BigCircle bc0[15:1](g2[15:1], p2[15:1], g[15:1], p[15:1], g[14:0], p[14:0]); 74 | 75 | // second line of circle 76 | wire [15:3] g3, p3; 77 | SmallCircle sc1[2:1](c[2:1], g2[2:1]); 78 | BigCircle bc1[15:3](g3[15:3], p3[15:3], g2[15:3], p2[15:3], g2[13:1], p2[13:1]); 79 | 80 | // third line of circle 81 | wire [15:7] g4, p4; 82 | SmallCircle sc2[6:3](c[6:3], g3[6:3]); 83 | BigCircle bc2[15:7](g4[15:7], p4[15:7], g3[15:7], p3[15:7], g3[11:3], p3[11:3]); 84 | 85 | // fourth line of circle 86 | wire [15:15] g5, p5; 87 | SmallCircle sc3[14:7](c[14:7], g4[14:7]); 88 | BigCircle bc3_15(g5[15], p5[15], g4[15], p4[15], g4[7], p4[7]); 89 | 90 | // fifth line of circle 91 | SmallCircle sc4_15(c[15], g5[15]); 92 | 93 | // last line - triangles 94 | Triangle tr0(sum[0], p[0], cin); 95 | Triangle tr[15:1](sum[15:1], p[15:1], c[14:0]); 96 | 97 | // generate cout 98 | buf #(1) (cout, c[15]); 99 | 100 | endmodule 101 | 102 | module KSA32(output [31:0] sum, output cout, input [31:0] a, b); 103 | 104 | wire cin = 1'b0; 105 | wire [31:0] c; 106 | wire [31:0] g, p; 107 | Square sq[31:0](g, p, a, b); 108 | 109 | // first line of circles 110 | wire [31:1] g2, p2; 111 | SmallCircle sc0_0(c[0], g[0]); 112 | BigCircle bc0[31:1](g2[31:1], p2[31:1], g[31:1], p[31:1], g[30:0], p[30:0]); 113 | 114 | // second line of circles 115 | wire [31:3] g3, p3; 116 | SmallCircle sc1[2:1](c[2:1], g2[2:1]); 117 | BigCircle bc1[31:3](g3[31:3], p3[31:3], g2[31:3], p2[31:3], g2[29:1], p2[29:1]); 118 | 119 | // third line of circles 120 | wire [31:7] g4, p4; 121 | SmallCircle sc2[6:3](c[6:3], g3[6:3]); 122 | BigCircle bc2[31:7](g4[31:7], p4[31:7], g3[31:7], p3[31:7], g3[27:3], p3[27:3]); 123 | 124 | // fourth line of circles 125 | wire [31:15] g5, p5; 126 | SmallCircle sc3[14:7](c[14:7], g4[14:7]); 127 | BigCircle bc3[31:15](g5[31:15], p5[31:15], g4[31:15], p4[31:15], g4[23:7], p4[23:7]); 128 | 129 | // fifth line of circles 130 | wire [31:31] g6, p6; 131 | SmallCircle sc4[30:15](c[30:15], g5[30:15]); 132 | BigCircle bc4_31(g6[31], p6[31], g5[31], p5[31], g5[15], p5[15]); 133 | 134 | // sixth line of circles 135 | SmallCircle sc5_31(c[31], g6[31]); 136 | 137 | // last line - triangless 138 | Triangle tr0(sum[0], p[0], cin); 139 | Triangle tr[31:1](sum[31:1], p[31:1], c[30:0]); 140 | 141 | // generate cout 142 | buf #(1) (cout, c[31]); 143 | 144 | endmodule 145 | 146 | module KSA64(output [63:0] sum, output cout, input [63:0] a, b); 147 | 148 | wire cin = 1'b0; 149 | wire [63:0] c; 150 | wire [63:0] g, p; 151 | Square sq[63:0](g, p, a, b); 152 | 153 | // first line of circles 154 | wire [63:1] g2, p2; 155 | SmallCircle sc0_0(c[0], g[0]); 156 | BigCircle bc0[63:1](g2[63:1], p2[63:1], g[63:1], p[63:1], g[62:0], p[62:0]); 157 | 158 | // second line of circles 159 | wire [63:3] g3, p3; 160 | SmallCircle sc1[2:1](c[2:1], g2[2:1]); 161 | BigCircle bc1[63:3](g3[63:3], p3[63:3], g2[63:3], p2[63:3], g2[61:1], p2[61:1]); 162 | 163 | // third line of circles 164 | wire [63:7] g4, p4; 165 | SmallCircle sc2[6:3](c[6:3], g3[6:3]); 166 | BigCircle bc2[63:7](g4[63:7], p4[63:7], g3[63:7], p3[63:7], g3[59:3], p3[59:3]); 167 | 168 | // fourth line of circles 169 | wire [63:15] g5, p5; 170 | SmallCircle sc3[14:7](c[14:7], g4[14:7]); 171 | BigCircle bc3[63:15](g5[63:15], p5[63:15], g4[63:15], p4[63:15], g4[55:7], p4[55:7]); 172 | 173 | // fifth line of circles 174 | wire [63:31] g6, p6; 175 | SmallCircle sc4[30:15](c[30:15], g5[30:15]); 176 | BigCircle bc4[63:31](g6[63:31], p6[63:31], g5[63:31], p5[63:31], g5[47:15], p5[47:15]); 177 | 178 | // sixth line of circles 179 | wire [63:63] g7, p7; 180 | SmallCircle sc5[62:31](c[62:31], g6[62:31]); 181 | BigCircle bc4_63(g7[63], p7[63], g6[63], p6[63], g6[31], p6[31]); 182 | 183 | // seventh line of circles 184 | SmallCircle sc6(c[63], g7[63]); 185 | 186 | // last line - triangles 187 | Triangle tr0(sum[0], p[0], cin); 188 | Triangle tr[63:1](sum[63:1], p[63:1], c[62:0]); 189 | 190 | // generate cout 191 | buf #(1) (cout, c[63]); 192 | 193 | endmodule -------------------------------------------------------------------------------- /montgomery1024.v: -------------------------------------------------------------------------------- 1 | `timescale 1ns / 1ps 2 | 3 | module montgomery( 4 | input clk, 5 | input resetn, 6 | input start, 7 | input [1023:0] in_a, 8 | input [1023:0] in_b, 9 | input [1023:0] in_m, 10 | output [1023:0] result, 11 | output done 12 | ); 13 | 14 | reg [1023:0] A, B, M, add_a, add_b; 15 | reg [10:0] n; 16 | reg [1025:0] r_result, C, D; 17 | reg d, subtract, add_start; 18 | reg [2:0]state; 19 | wire [1024:0] a, b; 20 | wire [1025:0] add_result; 21 | wire add_done, shift; 22 | assign shift = 0; 23 | 24 | adder dut 25 | (.in_a(a), 26 | .in_b(b), 27 | .subtract(subtract), 28 | .start(add_start), 29 | .result(add_result), 30 | .done(add_done), 31 | .clk(clk), 32 | .resetn(resetn), 33 | .shift(shift) 34 | ); 35 | 36 | always @(posedge(clk)) 37 | begin 38 | if (resetn == 0) 39 | begin 40 | A <= 0; 41 | B <= 0; 42 | M <= 0; 43 | C <= 0; 44 | D <= 0; 45 | d <= 0; 46 | n <= 1024; 47 | r_result <= 0; 48 | subtract<=0; 49 | add_start<=0; 50 | add_a <= 0; 51 | add_b <= 0; 52 | state<=0; 53 | end 54 | else 55 | begin 56 | case(state) 57 | 3'b000:begin//RESET 58 | A <= in_a; 59 | B <= in_b; 60 | M <= in_m; 61 | C <= 0; 62 | D <= 0; 63 | r_result <= r_result; 64 | n <= 1024; 65 | d <= 0; 66 | if (start == 1) 67 | begin 68 | state<=3'b001; 69 | end 70 | else 71 | begin 72 | state <= 3'b000; 73 | end 74 | 75 | end 76 | 3'b001:begin//START 77 | if (n == 0) 78 | begin 79 | state <= 3'b101; 80 | end 81 | else 82 | begin 83 | if (A[1023-(n-1)] == 1) 84 | begin 85 | add_a <= C; 86 | add_b <= B; 87 | subtract <= 0; 88 | add_start <= 1; 89 | state <= 3'b010; 90 | end 91 | else 92 | begin 93 | C <= C; 94 | state <= 3'b011; 95 | end 96 | end 97 | end 98 | 3'b010:begin//WAIT 99 | add_start <= 0; 100 | if (add_done == 1) 101 | begin 102 | C <= add_result; 103 | state<=3'b011; 104 | end 105 | else 106 | begin 107 | C <= C; 108 | state<= 3'b010; 109 | end 110 | end 111 | 3'b011:begin//C Check 112 | n <= n-1; 113 | begin 114 | if (C[0] == 0) 115 | begin 116 | C <= C >> 1; 117 | state <= 3'b001; 118 | end 119 | else 120 | begin 121 | add_a <= C; 122 | add_b <= M; 123 | subtract <= 0; 124 | add_start <= 1; 125 | state <= 3'b100; 126 | end 127 | end 128 | end 129 | 3'b100:begin//WAIT 130 | add_start <= 0; 131 | if (add_done == 1) 132 | begin 133 | C <= add_result >> 1; 134 | state <= 3'b001; 135 | end 136 | else 137 | begin 138 | C <= C; 139 | state<= 3'b100; 140 | end 141 | end 142 | 3'b101: begin //subtract 143 | add_a <= C; 144 | add_b <= M; 145 | subtract <= 1; 146 | add_start <= 1; 147 | state <= 3'b110; 148 | end 149 | 3'b110:begin//WAIT 150 | add_start <= 0; 151 | if (add_done == 1) 152 | begin 153 | D <= add_result; 154 | state <= 3'b111; 155 | end 156 | else 157 | begin 158 | D <= D; 159 | state<= 3'b110; 160 | end 161 | end 162 | 3'b111:begin //C 163 | if (D[1025] == 0) 164 | begin 165 | r_result <= add_result; 166 | end 167 | else 168 | begin 169 | r_result <= C; 170 | end 171 | d <= 1; 172 | state <= 3'b000; 173 | end 174 | endcase 175 | end 176 | end 177 | 178 | assign result = r_result[1023:0]; 179 | assign a = add_a; 180 | assign b = add_b; 181 | assign done = d; 182 | endmodule -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------